sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #45038
Re: [Question #661793]: Clever Hotkey Debouncing in Sikuli
Question #661793 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/661793
Description changed to:
In your docs, I suggest you update the pattern for hotkey debouncing.
The old pattern ends up creating a variable and an "IF" check for every
single new hotkey added, and is somewhat tedious. I suggest using a
clever python trick of function passing and lambdas. Here is a better
pattern. With this pattern, to add a new hotkey, you simply add a
function and addHotKey() and DONE:
doing = None
def do(command):
global doing
doing = command
running = True
def quitSikuli(e):
global running
popup("Exiting")
running = False
def helloWorld():
popup("Hello World")
Env.addHotkey("x", KeyModifier.ALT+KeyModifier.CTRL, quitSikuli)
Env.addHotkey("c", KeyModifier.ALT+KeyModifier.CTRL, lambda e: do(helloWorld))
while running:
if doing:
doing()
doing = None
wait(1)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.