sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #54503
Re: [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
Question #689241 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/689241
Status: Open => Answered
RaiMan proposed the following answer:
looks like some stopObserver overkill ;-)
my suggestion:
def boxObserve():
def changed(event):
global someChanges
event.changes[-1].click() #click on the last changed area
someChanges = True
event.stopObserver()
box = Region(684,552,266,371)
box.onChange(500, changed)
someChanges = False
box.observe(0.5,background=False)
if someChanges:
doSomethingAfterClicking() #Do this after clicking
else:
doSomethingIfNothingChanged() #Do this function if Observer didnt detect any changes.
some comments:
- in a handler should not be lengthy activities, because the main thread is paused meanwhile
- when the observe time is reached, the observer is stopped anyways
- when the handler is visited, event.changes contains at least one entry
- global variables can be used to communicate between handler and main thread
hope it helps
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.