← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #200790]: Move mouse while Sikuli is running?

 

Question #200790 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200790

    Status: Open => Answered

RaiMan proposed the following answer:
No, it is not possible to lock/secure the mouse in any way against
interferences by the user.

One thing you can do in all cases is to set 
Settings-MoveMouseDelay = 0

which lets the mouse "jump" directly to its end point.

What you can do additionally, is to generally make mouse actions on Locations only, means you should separate the find operation and the mouse action.
find("something.png")
click(getLastMatch())

So you could check directly before, that the mouse is still at its place from the last action, and afterwards, that it is still at the intended location, so it is most probable, that the click has hit the correct location.
find("something.png")
if not mousePos == Env.getMouseLocation(): print "mouse is corrupted by other process or user" 
mousePos = getLastMatch().getTargetOffset()
click(mousePos)
if not mousePos == Env.getMouseLocation(): print "mouse is corrupted by other process or user" 

You could even add a subprocess, that constantly checks that mouse
movements are only the ones intended by the script, so you could pause
the script at critical points, until the mouse is free again.

But be aware: Generally, Sikuli scripts are intended to be used without
interference by a user and that, if it happens, the situation on the
screen usually changes in a way, that might make a script unusable.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.