sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #10322
Re: [Question #195347]: wait for image A or wait for image B
Question #195347 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/195347
Status: Open => Answered
RaiMan proposed the following answer:
--- observe()
... only observes for 3 seconds (the standard waiting tim).
If you want a longer observation, use
observe(some_time)
... where some_time is a value in seconds
During this kind of observe(), the script pauses (max for the given time, if nothing appears).
But it also consumes the given time, if you do not stop the observation in case something appears.
With this form (observe pauses script) you have to do this in the
handler:
e.g.
def handler(event):
event.region.stopObserver()
click(A )
--- your other question
Thanks that works now but i dont seem to understand this part can u explain?
isImgA_or_ImgB = False
while not isImgA_or_ImgB:
wait(1)
Since in my example I used the form of observe() that runs in parallel
in the background, the script continues. In this case I have to set up
some actions in the script to not let it end (in a normal workflow you
will have a natural waiting point some where in the ongoing script: e.g.
wait for the next GUI element).
So here I have a loop, that simply checks every second, wether one of
the handlers was fired (using the global variable isImgA_or_ImgB).
And stopping the observing is done in the main workflow, since when
running the observation in the background, usually the main workflow
"knows" that the observation is no longer needed.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.