← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #688902]: How to store the image of the region, where a find op did not work

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Until the 2.0.x versions, it is a bit tricky (will be much easier in
2.1.x).

- a version, when the screen does not change immediatly after the find
failed

reg = Region(14,8,491,389) # where to search
img = "img.png" # what to search
if (reg.has(img)):
  reg.getLastMatch().highlight(2) # if success
else:
  # if no success
  fileName =  reg.getScreen().capture(reg).getFile("<folder to store the image>", "<a name for the image>")

<folder to store the image> an absolute path
<a name for the image> a name for the image 

if you use:
  fileName =  reg.getScreen().capture(reg).getFile("<folder to store the image>")
the image name will be created as
sikuliximage-1582449259193.png (timestamped)

- if the screen might already have changed after the FindFailed or you
want the exact image that was used for the last search trial:

  fileName = reg.getScreen().lastScreenImage.getFile("<folder to store
the image>", "<a name for the image>")

fileName is the created absolte filename of the stored image (print
fileName)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.