Page 1 of 1

AutoHotKey Script suddenly stopped

Posted: 23 Jun 2017, 02:32
by lennyli
Hi

I wrote a console application that will generate a list of commands for auto hot key to press keys on a specific voice recording program. The amount of instruction is high because our goal is to automate this task for our daily data processing. All it is doing is to open some calculated time and save the file at a specific filepath.
The .ahk file is to run on a windows 7 desktop PC. The program works OK on most days. But occasionally it will stop running in the middle of the processing. I had to write the script so that it will append a unique random number to a log file so we can manually check how much progress is done.
Any ideas why the script will stop on its own? Now we have to edit the script to relaunch it if it suddenly stopped half way.

Thanks for your help.

Re: AutoHotKey Script suddenly stopped

Posted: 25 Jun 2017, 20:44
by divanebaba
If you post your code and enough information about the desired functions, everybody would be able to analyse and maybe help.
Without advanced informations any ideas would not be helpful.

Re: AutoHotKey Script suddenly stopped

Posted: 26 Jun 2017, 02:01
by lennyli
The script looks something like this: (a shorten version)

; DTI Instruction for AudoHotKey to run simulating user input on FTR Gold Sound Clipper at 25/05/2017 14:59:15
Run, C:\Program Files (x86)\FTR\ForTheRecord\TheRecordPlayer.exe
WinWait, TheRecord Player
;=============================================
;=====FIRST TIME RUNNING AUTOHOTKEY====
Sleep, 2000
send,{tab 11}{space} ;click file open button
;======================================
Sleep, 1000
send,{tab 6}{space} ;click the other button in file dialog
WinWaitActive, Open other...
send,\\10.33.4.12\Audio\public\20170524\DC-45
Sleep, 2000
send, {enter}
Sleep, 3000
send, +{tab} ;shift tab
Sleep, 2000
send, ^a ;press control a to select all
Sleep, 2000
send, !o
send, {tab 24} ;24 tab to goto start of time
send, 093451 ;start time
send, {tab 2}
send, 100421 ;end time
send, {tab 5}{space} ;click save button
WinWaitActive, Save Copy To
send, !f ;send Alt F
send, \\10.33.4.21\testaudio\2016\DCCJ3121-16
send, {enter}
Sleep, 2000 ;wait 2 secs to Not to click cancel button
WinWaitActive, TheRecord Player
send, {enter} ;click the successfuly saved OK button on TheRecord Player dialog box
FileAppend,9058467774`n, D:\AutoHotKeyActionCheckPoint.log
;========SECOND TIME RUNNING AUTOHOTKEY========
Sleep, 2000
send,+{tab} ;shift tab to click file open button
send,{space} ;click file open button
;==============================================
Sleep, 1000
send,{tab 6}{space} ;click the other button in file dialog
WinWaitActive, Open other...
send,\\10.33.4.12\Audio\public\20170524\DC-45
Sleep, 2000
send, {enter}
Sleep, 3000
send, +{tab} ;shift tab
Sleep, 2000
send, ^a ;press control a to select all
Sleep, 2000
send, !o
send, {tab 24} ;24 tab to goto start of time
send, 102034 ;start time
send, {tab 2}
send, 103313 ;end time
send, {tab 5}{space} ;click save button
WinWaitActive, Save Copy To
send, !f ;send Alt F
send, \\10.33.4.21\testaudio\2016\DCCJ3121-16
send, {enter}
Sleep, 2000 ;wait 2 secs to Not to click cancel button
WinWaitActive, TheRecord Player
send, {enter} ;click the successfuly saved OK button on TheRecord Player dialog box
FileAppend,8867089402`n, D:\AutoHotKeyActionCheckPoint.log
;========SECOND TIME RUNNING AUTOHOTKEY========
Sleep, 2000
send,+{tab} ;shift tab to click file open button
send,{space} ;click file open button
;==============================================
Sleep, 1000
send,{tab 6}{space} ;click the other button in file dialog
WinWaitActive, Open other...
send,\\10.33.4.12\Audio\public\20170524\DC-45
Sleep, 2000
send, {enter}
Sleep, 3000
send, +{tab} ;shift tab
Sleep, 2000
send, ^a ;press control a to select all
Sleep, 2000
send, !o
send, {tab 24} ;24 tab to goto start of time
send, 105321 ;start time
send, {tab 2}
send, 105501 ;end time
send, {tab 5}{space} ;click save button
WinWaitActive, Save Copy To
send, !f ;send Alt F
send, \\10.33.4.21\testaudio\2016\DCCJ3121-16
send, {enter}
Sleep, 2000 ;wait 2 secs to Not to click cancel button
WinWaitActive, TheRecord Player
send, {enter} ;click the successfuly saved OK button on TheRecord Player dialog box
FileAppend,1701574597`n, D:\AutoHotKeyActionCheckPoint.log
send, !{F4} ;alt F4 to close
Return

Re: AutoHotKey Script suddenly stopped

Posted: 26 Jun 2017, 03:07
by divanebaba
I don't have FTR Gold Sound Clipper installed, so I can't test your script and even I don't know, if the menu items and the controls are accessible by ahk commands like Control, ControlGetText, ControlSetText, ControlSend, WinMenuSelectItem etc.
The listed controls and some more are all able to access foreign controls, like buttons, radio and checkbox controls, menu items and so on.
These commands are much more faster and more reliable than simulating human behavior. These commands can't loose their focus, so they are recommended if usable.
I don't know if FTR Gold Sound Clipper controls are accessible with ahk. You have to try. If it works, you have to rewrite your script but this will be very advantageous for you.
To identify the names of the foreign controls, use ahk window spy. Move the mouse cursor over the controls and window spy (the new name is window info) will show thei ClassNN, wich are the names of the control parameter to use in the listed commands.

I see you've started one another topic for the same case. It is recommended to modify the subject of the topic and not starting a new topic with the same case, even when you have another question.
Starting more topics with almost identical problem to solve has a spamming character. :crazy:
Try some of the listed commands.

Re: AutoHotKey Script suddenly stopped

Posted: 26 Jun 2017, 21:57
by lennyli
Thanks for your reply

Re: AutoHotKey Script suddenly stopped

Posted: 26 Jun 2017, 22:15
by lennyli
However, your suggestion to use control commands cannot explain why the autohotkey script will stop in the middle of running.

Re: AutoHotKey Script suddenly stopped

Posted: 27 Jun 2017, 12:13
by divanebaba
You`re often using the WinWaitActive command. If the specified window is not active, this command will stay waiting.
Inserting the third parameter, for continuing after specified time, could make that your virtuell keys are sended to not existing windows.
You can find out, where your script is stopping, by inserting a routine to check the state of the window and give feedback.
Modifying every WinWaitActive command like sample below, could show the stopping part.
Spoiler
Maybe the DetectHiddenWindows command can even help too.

It is even possible, that your specified window already exists but is not active. You can use IfWinExist instead ofWinActive() like sample in the code below
Spoiler
There are so many ways to check the stopping point, I can't listen them all.
Spoiler