sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #31331
Re: [Question #264188]: Have background observation interrupt/pause main thread
Question #264188 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/264188
RaiMan proposed the following answer:
I have a solution for that now:
# a Jython script:
def handler(e):
print("in handler")
Device.setShouldTerminate() # request the termination at next mouse action
print("leaving handler")
Mouse.setMouseMovedCallback(handler) # the handler will be called when the user moves the mouse
for i in range(3):
hover()
wait(0.5)
hover(getTopLeft())
wait(0.5)
while the main loop is running, I move the mouse.
this is detected and the handler is called.
the handler requests termination and returns.
before starting the next hover(), the script is terminated with an AssertionError:
the relevant debug output:
[debug] JythonScriptRunner: runPython: running script from IDE:
/Volumes/HD6/rhocke-plus/SikuliX-2014/StuffContainer/testScripts/testCallback/testMouse.sikuli
[debug] Region: hover: L(960,600)@S(0)[0,0 1920x1200]
[debug] Region: hover: L(0,0)@S(0)[0,0 1920x1200]
[debug] Region: hover: L(960,600)@S(0)[0,0 1920x1200]
[debug] Region: hover: L(0,0)@S(0)[0,0 1920x1200]
--- detecting and showing the external mouse move
[debug] Device: Mouse: moved externally: now (1150,501) was (960,600) (mouseMovedResponse 3)
[debug] toggle highlight R[1140,491 20x20]@S(0)[0,0 1920x1200] E:Y, T:3,0: true
[debug] highlight R[1130,481 40x40]@S(0)[0,0 1920x1200] E:Y, T:3,0 for 1.0 secs
[debug] toggle highlight R[1140,491 20x20]@S(0)[0,0 1920x1200] E:Y, T:3,0: false
--- handler is called
in handler
[debug] Device: setShouldTerminate: request issued
leaving handler
--- throwing AssertionError
[error] script [ testMouse ] stopped with error in line 11
[error] java.lang.AssertionError ( java.lang.AssertionError: aborted by Sikulix.MouseMovedCallBack )
[debug] Sikulix: cleanUp: 0
So in your situation:
before leaving the background observe handler, you say:
Device.setShouldTerminate()
and before processing the next mouse action the AssertionError is
thrown/raised.
I will now start a new nightly build, so it will be available latest in
1 h for testing
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.