sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #52294
Re: [Question #682734]: Unable to simultaneously listen to global hotkeys and do desktop surveillance
Question #682734 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/682734
Description changed to:
Hi, just getting into SikuliXx 1.1.4,
What I'm trying to achieve is have a global exit hotkey as described
under
https://sikulix-2014.readthedocs.io/en/latest/interaction.html?highlight=Env.addHotkey
#listening-to-global-hotkeys
while at the same time be able to have the script constantly monitor the
desktop for images to pop up.
Here's my code thus far:
# hotkey to stop the script
exitScript = False; # global to communicate with main loop
def xHandler(event):
global exitScript
exitScript = True # tell main loop that hotkey was pressed
# add the hotkey with its handler
Env.addHotkey("x", KeyModifier.CTRL + KeyModifier.SHIFT, xHandler)
while True:
if has(Pattern("1.png").similar(0.66)):
click(Pattern("1.png").similar(0.66))
if has ("2.png"):
click("2.png")
paste("email@xxxxxxxxx")
if has ("3.png"):
click()
if (exitScript):
exit()
The way I have it here works for one iteration.
I can exit the lopp at any time by pressing the defined keyboard shortcut cominbation.
Those three images are successfully found and clicked on once they appear on the screen.
However, soon after that the loop fails because 1.png cannot be found.
Here's the log:
[log] CLICK on L[1130,708]@S(0) (275 msec)
[log] CLICK on L[1025,442]@S(0) (273 msec)
[log] CLICK on L[1272,599]@S(0) (272 msec)
[error] script [ Test ] stopped with error in line 18
[error] FindFailed ( 1.png: (568x851) seen at (846, 283) with 0.75 in R[0,0 1920x1200]@S(0) )
[error] --- Traceback --- error source first
line: module ( function ) statement
18: main ( <module> ) click("1.png")
[error] --- Traceback --- end --------------
So is there a logic to be able to constantly monitor for desktop activity until I press the global exit hotkey?
Thanks for your help and keep up the good work.
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.