sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #25115
Re: [Question #246342]: Do onAppear and observe work? [1.0.1]
Question #246342 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/246342
Status: Open => Answered
RaiMan proposed the following answer:
ok, now you are stuck with the observe bugs in 1.0.1
observe in background (observe(time, True)) simply puts the observe in a
thread and continues with the next statement. Since the script might be
terminated before the observe has success, in IDE the thread simply runs
and silently blocks any observe for the same region. It is killed only,
when the IDE is stopped.
The simple "inline" observe (observe(time)) waits for success but max
for the given time and then continues with the next statement after the
observe (in this case the observe is stopped anyway ;-)
The automatic repeat does not work (a bug).
So with 1.0.1 if you really want a parallel watchdog, you have to use
the threading feature yourself:
import thread
def myThread(parm1, parm2, ...):
# here goes the code to be processed in parallel
thread.start_new_thread(myThread, (parm1, parm2, ))
more info: https://docs.python.org/2.6/library/thread.html
Be aware: as with observe in background the usage of mouse and keyboard is not coordinated between main and thread.
At least with this Python solution you have the chance to guard critical sections using the thread module's lock feature.
version 1.1.0 will have a working and feature-added observe and will
have mouse/keyboard coordination between threads. But it is not ready
yet, sorry ;-)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.