sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #04861
Re: [Question #169307]: OBSERVE(FOREVER) but FINDFAILED
Question #169307 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/169307
Status: Open => Answered
RaiMan proposed the following answer:
In any case: You cannot start a new observe() inside the handler.
*** So your basic code should be:
def myH(e):
hover(picture)
stopObserver()
picture = "your-captured-image.png" # only one capture / multiple use
onAppear(picture, myH)
observe(FOREVER)
*** So if you want this to continue this for ever:
def myH(e):
hover(picture)
stopObserver()
picture = "your-captured-image.png" # only one capture / multiple use
onAppear(picture, myH)
while True:
observe(FOREVER) # this will start observing again, when handler has stopped the observer
But this does not make sense, because I cannot see any action to wait
until the image disappears to start a new observation.
*** do not make another find in the handler
in the handler, you know the match of the onAppear(), so you can use:
def myH(e):
hover(e.match)
stopObserver()
(look: http://sikuli.org/docx/region.html#observing-visual-events-
in-a-region)
*** using exists() instead of observe()
for these situations (observing in foreground - script waits) I prefer to use loops and exists()
picture = "your-captured-image.png" # only one capture / multiple use
while True: # run forever
while not exists(picture, 0): # wait for picture
wait(1)
hover(getLastMatch())
wait(10) # or something else to make picture vanish
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.