← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #258504]: Sikuli pause and capture?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
This feature is on the list for version 1.2

But already now you can do it this way:

have this script as example:

img = "icon.png"
r = <some region> 
r.highlight(2)
r.wait(img, 0)

if the image img is not found in the region r, this would crash with a
FindFailed exception.

now change your script so:

img = "icon.png"
r = <some region> 
r.highlight(2)
r.setFindFailedResponse(PROMPT) # <--- added
r.wait(img, 0)

Now you will get a prompt if the image is not found with buttons Retry, Skip, Abort
This feature (see docs: http://sikulix-2014.readthedocs.org/en/latest/region.html#exception-findfailed) allows to e.g. rearrange the GUI in some situations and then continue the script with the before failed find.

So this is half of what you need.

The other half is a bit tricky, but works:
- run the script on the command line
- have the script opened in parallel in the IDE (do not run it from here now)

if the prompt pops up, make the corrected snapshot and take care, that you name the image exactly as it was before.
To name the image correctly use the IDE Preview - it should ask, wether you want to overwrite the existing image.
Now at the poup say retry after having arranged the windows as needed for your script to continue correctly.
Now the script should succeed with the find and continue.

If you use version 1.1.0 you need an additional setting:

Settings.setImageCache(0) # <--- added
img = "icon.png"
r = <some region> 
r.highlight(2)
r.setFindFailedResponse(PROMPT) 
r.wait(img, 0)

this is needed to switch off image caching and to force the reload of
the image.

All this will be seamlessly integrated in version 1.2

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