sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #06856
Re: [Question #178538]: IDE: with: selects whole screen instead of specified region on rerun --- workaround
Question #178538 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/178538
RaiMan posted a new comment:
-- error with click(m1)
Your usage at this point in your script is
m1 = capture(x,y,w,h)
click(m1)
the rectangle (x,y,w,h) is internally captured and the image is stored
in a temporary file. Then in preparation of the click, this image is
searched and should be found, since it was captured nearly in the same
moment.
My first idea: Since you are using this in an endless loop, there might be a problem with the generation of temporary filenames and or files, when this process is repeated too often and too fast.
But testing this scenario, I did not notice any problems (on my Mac): 50 repetitions of capture/find and the similarity score was always 1.0.
So this might not cause the problem.
Another more possible reason: you are randomizing width and height for the captured rectangle. I did not check this calculations. Since the search is done in a small region afterwards, it might be, that there are cases, where part of the image is outside of the region, which will produce a FindFailed exception.
So check your randomizing bounds. The captured images must be inside the restricting region in all cases.
-- is there any way to force the script running forward without stopping on the error?
generally the only way is to use try:/except:
try:
print "some code, that might crash"
1 / 0
except:
print "code crashed, but it does not matter"
print "script is still running"
In the special case of FindFailed exceptions in Sikuli scripts, there
are some options, how to handle these situations generally by using
options: http://sikuli.org/docx/region.html#exception-findfailed
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.