Question #268710 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/268710
Status: Open => Answered
RaiMan proposed the following answer:
ok, that was not obvious in you question.
I understand:
you have a situation (occasionally), where you find an image using
exists(image) and after a short time later, this image might have vanished
already (occasionally), so a following click(image) causes a FindFailed error
and stops the script at this point.
If this ever happens, you want the script to continue.
To generally avoid delays between the find op and a click, you should use
Settings.MoveMouseDelay = 0
to not have this "animated" mouse move, which lasts 0.5 seconds in the standard
setting.
But with this, you still have some milliseconds delay.
# solution 1:
try:
click(image)
except:
pass # do nothing (or whatever you want)
# solution 2:
if exists(image):
click(getLastMatch()) # does not search again, uses the match from the
exists
else:
pass # do nothing (or whatever you want)
Both solutions are equivalent in the outcome:
if the image is found, it is clicked with some milliseconds delay.
If the image is not there, no click happens and continues with the stuff in the
except/else section
This can still happen:
If the image vanishes during the some milliseconds after the find op has
finished and returned the match region, but before the click is done at the
center of the match region, then the click might trigger an unwanted action
depending on the state of the GUI in that moment at this point.
… but this cannot be avoided generally: what ever you do, to check if the image
is still there, it will be some milliseconds delay, before the mouse click is
issued.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp