sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #45048
Re: [Question #661793]: Clever Hotkey Debouncing in Sikuli
Question #661793 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/661793
Status: Open => Answered
RaiMan proposed the following answer:
thanks for the inspiration.
... but I do not agree with your opinion about the current example in
the docs: it is one of many possible setups, that wants to keep all
processing in the main part of the script with the option to decide, at
what place in the main workflow one wants to process the intention of
the hotkey or even ignore it at this time.
your example:
of course an example of using lambdas and functions (... but this is normal Python - by no way a trick).
... but to get what you want, not needed.
the minimum solution (using a lambda to exit the script from the handler
- brute force lite):
Env.addHotkey("x", KeyModifier.ALT+KeyModifier.CTRL, lambda e: exit())
def helloWorld(e):
popup("Hello World")
Env.addHotkey("c", KeyModifier.ALT+KeyModifier.CTRL, helloWorld)
# this loop is not necessary, it only stands for some
# time consuming main workflow to keep this example running
while true:
wait(1)
... true for this also: you simply add a function and addHotKey()
lambdas instead of a function name in addHotKey() only make sense if:
- you want to decide about the visited handler function at runTime
- and/or you want to handover parameters to your handler (instead of using globals)
I will add an additional example to the docs show these more
sophisticated cases.
Nevertheless thanks again for your efforts and the feedback.
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.