Issue with Hotkey
I'm trying to set a hotkey to end a script which is running in the IDE.
=======
def exitHotkey(event):
print "Exit"
exit()
Env.addHotkey(
print "start"
wait(60)
print "stop"
=======
But if i press the Hotkey, the script and the IDE is closed and i have to restart it.
I tried other hotkeys but no success. Calling the function manually works fine.
OS: Linuxmint 20.1 Cinnamon
Sikulix: 2.0.4
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Sikuli Edit question
- Assignee:
- No assignee Edit question
- Last query:
- 2021-02-20
- Last reply:
- 2021-02-21
RaiMan (raimund-hocke) said : | #1 |
exit() cannot be used in the handler, since it stops the application here (hence the IDE).
You have to tell the main script, that the hotkey was pressed simply with a global variable:
def exitHotkey(event):
global shouldStop
Do.
shouldStop = True
Env.addHotkey(
shouldStop = False
while not shouldStop:
wait(1)
bitboy (zeus557) said : | #2 |
Thx for your answer. What i had in mind was my own selected Hotkey for the combination SHIFT + ALT + c which immediately stops the running script and shows the IDE again.
Imagine having some time consuming functions in your main loop, so it could take a while until the exit() is really executed. This could be confusing.
Can you help with this problem?
Provide an answer of your own, or ask bitboy for more information if necessary.