Need to create a simple script, agree on a donation
Need to create a simple script, agree on a donation
We need a very simple script:
1.Take one line from a text or file. There can be many such lines.
2. Insert
3. press enter
Repeat the loop.
Ready for a little donation
1.Take one line from a text or file. There can be many such lines.
2. Insert
3. press enter
Repeat the loop.
Ready for a little donation
Re: Need to create a simple script, agree on a donation
Code: Select all
; This script pastes text from a file.
#Requires AutoHotkey v2.0
filePath := A_ScriptDir '\test.txt'
paste(filePath)
paste(filePath) {
If FileExist(filePath)
SendText FileRead(filePath)
Else MsgBox 'File not found.`n`n' filePath, 'Error', 48
}
Re: Need to create a simple script, agree on a donation
First of all, thank you very much for responding to help!
I need to insert text the way this script does. But now I need at least some way to specify where to insert this text. For example, to point the mouse and run the script on the button. Because running this script, it starts inserting text just at the moment of launching the script.
But the solution does work, I'm very happy watching what I can't apply.
I need to insert text the way this script does. But now I need at least some way to specify where to insert this text. For example, to point the mouse and run the script on the button. Because running this script, it starts inserting text just at the moment of launching the script.
But the solution does work, I'm very happy watching what I can't apply.
Re: Need to create a simple script, agree on a donation
Code: Select all
; This script pastes text from a file.
#Requires AutoHotkey v2.0
filePath := A_ScriptDir '\test.txt'
F3::paste(filePath)
paste(filePath) {
Static txt := "" ; Reuse the same text
If txt = ""
If FileExist(filePath)
txt := FileRead(filePath)
Else MsgBox 'File not found.`n`n' filePath, 'Error', 48
SendText txt
}
Code: Select all
; This script pastes text from a file.
#Requires AutoHotkey v2.0
filePath := A_ScriptDir '\test.txt'
F3::paste(filePath)
paste(filePath) {
If FileExist(filePath)
SendText FileRead(filePath) ; Get the file's current text
Else MsgBox 'File not found.`n`n' filePath, 'Error', 48
}
Re: Need to create a simple script, agree on a donation
Great, that's 80% of what I need.mikeyww wrote: ↑28 Jan 2023, 18:30Or:Code: Select all
; This script pastes text from a file. #Requires AutoHotkey v2.0 filePath := A_ScriptDir '\test.txt' F3::paste(filePath) paste(filePath) { Static txt := "" ; Reuse the same text If txt = "" If FileExist(filePath) txt := FileRead(filePath) Else MsgBox 'File not found.`n`n' filePath, 'Error', 48 SendText txt }
Explained: Introduction and simple examplesCode: Select all
; This script pastes text from a file. #Requires AutoHotkey v2.0 filePath := A_ScriptDir '\test.txt' F3::paste(filePath) paste(filePath) { If FileExist(filePath) SendText FileRead(filePath) ; Get the file's current text Else MsgBox 'File not found.`n`n' filePath, 'Error', 48 }
Can you tell me where it is more convenient for you to send the donate? I am in Ukraine and I have some difficulties with transfers. Write a convenient way for you and I will try to find a solution.
I have tested everything and I have two theses:
1. When the text is inserted, is enter pressed? I need to press enter after each line.
2. Is it possible to add a small pause after each submission ( pressing enter) ?
Thank you very much, we now have light on for +-3 hours a day and you have helped me a lot!
Re: Need to create a simple script, agree on a donation
Hello,
Update is below. Yes, the line feed is included. Feel free to test the script to confirm that.
Thank you for your kind offer. Please save your funds for another time, or you can always donate to the AutoHotkey Foundation. I have no connection to it.
Best of luck!
Update is below. Yes, the line feed is included. Feel free to test the script to confirm that.
Code: Select all
; This script pastes text from a file.
#Requires AutoHotkey v2.0
filePath := A_ScriptDir '\test.txt'
F3::paste(filePath, WAIT := 350)
paste(filePath, wait := 0) { ; For each file line, paste text and line feed, with intervening delay
If FileExist(filePath) {
Loop Read filePath
Sleep(wait * (A_Index > 1)), SendText(A_LoopReadLine '`n')
} Else MsgBox 'File not found.`n`n' filePath, 'Error', 48
}
Best of luck!
Re: Need to create a simple script, agree on a donation
Perfect. Thank you!