sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #41544
Re: [Question #462100]: Setup a hotkey for Sikuli to execute code
Question #462100 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/462100
Status: Open => Answered
RaiMan proposed the following answer:
a generic example.
To put the payload into the main loop makes things more transparent
IMHO.
# hotkey to stop the script
hotKeyX = False; # global to communicate with main loop
def xHandler(event):
global hotKeyX
hotKeyX = True # tell main loop that hotkey was pressed
# add the hotkey with its handler
Env.addHotkey("x", KeyModifier.CTRL + KeyModifier.SHIFT, xHandler)
# function hotkey: something to do when pressed
hotKeyN = False;
def nHandler(event):
global hotKeyN
hotKeyN = True
Env.addHotkey("n", KeyModifier.CTRL + KeyModifier.SHIFT, nHandler)
# the main loop, that simply waits for pressed hotkeys
# which are then processed
count = 0;
while True:
if (hotKeyX):
popup("processing ctrl+shift+x: stopping")
exit()
if (hotKeyN):
hotKeyN = False
count += 1
popup("processing ctrl+shift+n: %d" % count)
wait(1)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.