sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #29399
Re: [Question #258197]: Using observe to continuously look for pattern and take actions
Question #258197 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/258197
Status: Open => Answered
RaiMan proposed the following answer:
-- 1. this only works with version 1.1.0
-- 2. as the parameters say: the observe runs in background completely
parallel to the main script. Just call the idleObserver once at the
beginning.
-- 3. concurrent mouse and keyboard usage:
up to version 1.0.1 it could happen, that the handler (Disconnected in your case) took over in the middle of a mouse action in the main workflow, which usually led to crashes.
There was no easy way, to avoid such situations.
Now with version 1.1.0 mouse actions like click are "atomical" operations , that are completed, before another thread can do his mouse action. It is even possible to pack a serious of mouse actions into one "transaction", that is completed, before any other thread can use the mouse.
The features are very new and not tested in all aspects, but should work in your situation out of the box with a simple click.
-- 4. how to
once before going into your main flow:
idleObserver()
which starts the observing in background
your handler should have:
def Disconnected(event):
#This function closes disconnect message using a click
event.region.click(button) # clicks the button in the observed region
event.repeat(someSeconds) # waits someSeconds until continuing to observe (someSeconds = 0: continue without waiting)
without the repeat(), the observation would terminate after the first
appearance.
in your main loop nothing has to be done: if the handler gets active
with it's click, the next mouse action in the main workflow simply waits
until the click in the handler is completed and then continues.
Be aware: there are no automatics currently, that prevent your main workflow to crash, if the popup you are waiting for in this moment hides something you are waiting for in the main workflow.
The only means in the moment: raise the waiting time accordingly for the critical sections/finds
One more thing:
Sorry, but this is not yet in the docs.
So come back with more questions.
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.