 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
cr33p
Joined: 21 Oct 2004 Posts: 5 Location: Fort Bragg, NC
|
Posted: Tue Nov 16, 2004 1:14 pm Post subject: ControlSend with FileReadLine and ... FileRemLine? |
|
|
Ok, I'm trying my darndest to automate some of the terribly repetitive tasks I have here at work. One of them basically involves inputting a patient ID and following it with a number of keystrokes, then looping to the next ID.
Anyway, my existing script is at home on my thumb drive :\ It just utilizes FileReadLine and Send statements to go through each ID in a file.
SO! What I'd really like to be able to do is this:
read line from fileID.txt, ControlSend appropriate keystrokes
upon completion of each ID, append ID to fileIDComplete.txt, and remove ID from fileID.txt
loop until fileID.txt is empty
Wow I'm really not very good at vocalizing what I'm trying to do - did that make any sense?
Anyhow, thanks in advans, and I'll post my existing script as soon as I get home. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Tue Nov 16, 2004 8:22 pm Post subject: |
|
|
Here's a starting point: | Code: | SetWorkingDir, C:\My Files ; Change this to the folder containing your files.
OutputFile = fileIDComplete.txt
IfExist, %OutputFile%
{
MsgBox, 4,, Delete %OutputFile%?
IfMsgBox, Yes
FileDelete, %OutputFile%
;else the file will be appended to.
}
; The below will loop until fileID.txt is empty:
Loop, read, fileID.txt, %OutputFile%
{
ControlSend, MyControl, keystrokes %A_LoopField% keystrokes, WinTitle
FileAppend, %A_LoopField%`n ; Append to output file.
} |
| Quote: | | remove ID from fileID.txt | That would be a little harder to do, and it seems inefficient. Are you sure it's necessary? |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 17, 2004 11:40 am Post subject: |
|
|
Sweet, thanks for the reply - I'll start cookin.
And as far as removing the line from the initial file - it's more of a convenient failsafe for me. Sometimes, for random reasons, the system I log into just drops the connection, so I have to get logged in again and start over. Then I have to dig through the file of completed IDs and figure out where to start again on the initial list.
So either truncating the initial file, or doing some sort of file comparison to exclude IDs that are in BOTH files would be convenient. But certainly not necessary :] |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 17, 2004 11:44 am Post subject: |
|
|
And here's the way I'm doing it now, which was actually one of my very first AHK scripts:
| Code: |
Loop, read, input.txt, output.txt
{
SetKeyDelay, 500
Send, 20/%A_LoopReadLine%{ENTER}
Send, {ENTER 3}
Sleep, 2000
Send,;RAD;71020;;LAB;G-6-PDH;SICKLE;;;{ENTER}
Sleep, 2000
Send, ANDERSON,WARNER
Sleep, 2000
Send, {ENTER 4}
Sleep, 2000
Send, SF{SPACE}PHYSICAL{ENTER 9}
Sleep, 2000
Send, DIAG{ENTER 15}
Sleep, 2000
Send, Q{ENTER}
FileAppend, %A_LoopReadLine%`n, output.txt
}
|
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Wed Nov 17, 2004 12:01 pm Post subject: |
|
|
Looks good. For slightly better file-writing performance, you can omit the last parameter from the following line. This is because output.txt is the Loop's output file so it is automatically kept open for writing:
FileAppend, %A_LoopReadLine%`n, output.txt |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|