Play alert when sikuli script fails

Asked by Kevin

I have a script that I use to bot in a game. After running for several hours sometimes the lag causes a window to not pop up correctly and then my script ends after waiting and then sikuli pops back up showing the line error. Is there a way I can have it launch an audio file to alert me that sikuli stopped before ending?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

you can wrap your whole script, parts of it or even only one line into a try: except: construct and use run("some command") to trigger a command, that plays the audio.

try:
   wait(some_image, 20)
except:
    run("command_play_audio.cmd") # supposing you are on Windows

usually the script would abort with a FindFailed error if the waiting time of 20 seconds elapses without the image having appeared.

With the above construct, the code in the except: branch will be executed.

Can you help with this problem?

Provide an answer of your own, or ask Kevin for more information if necessary.

To post a message you must log in.