AutoHotKey Script suddenly stopped

Get help with using AutoHotkey and its commands and hotkeys
lennyli
Posts: 8
Joined: 18 May 2017, 01:12

AutoHotKey Script suddenly stopped

23 Jun 2017, 02:32

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.
lennyli
Posts: 8
Joined: 18 May 2017, 01:12

Re: AutoHotKey Script suddenly stopped

26 Jun 2017, 02:01

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
User avatar
divanebaba
Posts: 786
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: AutoHotKey Script suddenly stopped

26 Jun 2017, 03:07

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.
lennyli
Posts: 8
Joined: 18 May 2017, 01:12

Re: AutoHotKey Script suddenly stopped

26 Jun 2017, 21:57

Thanks for your reply
lennyli
Posts: 8
Joined: 18 May 2017, 01:12

Re: AutoHotKey Script suddenly stopped

26 Jun 2017, 22:15

However, your suggestion to use control commands cannot explain why the autohotkey script will stop in the middle of running.
User avatar
divanebaba
Posts: 786
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: AutoHotKey Script suddenly stopped

27 Jun 2017, 12:13

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

Return to “Ask For Help”

Who is online

Users browsing this forum: flyingDman, Google [Bot], heroji, kdk1323, kingtermite and 57 guests