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

    Status: Open => Answered

RaiMan proposed the following answer:
-- find vs. exists
in case of not found, find throws an error (FindFailed) which usually will 
abort the script at this point.
exists returns False in this case, so the script can continue (which is the 
reason you can use it with if ...).
But exists is more comparable with wait, since it accepts e wait time as 2nd 
parameter (which can be 0, to tell exists to return immediately after the first 
search try in all cases and not wait the standard 3 secs if not found)

So in your case "if a or b or c or ..."  should use this version:

if exists(<image.jpg>, 0) or exists (<image2.jpg>, 0) or exists...

With your version having e.g. 4 exists and only the last one matches,
then it will take at least 9 secs (3 times not found time 3 secs),until
your script continues.

with the suggested version this will take max 3-4 secs.

But be aware:
at least one of the images must be fully present on the screen at the time the 
if is processed. If this is not the case for sure, you have to do something in 
the else branch or put a wait() before the if.

--- restricting the search to a region ...
.... which increases reliability and speed of a script (the smaller the region 
and/or the smaller the dimension difference between image and region, the 
faster the search).

principla use: reg.exists() or reg.click()
where reg is a region, that is evaluated before somehow.

In your case as a first step, you should define the regions needed, 
interactively:
reg1 = selectRegion()
reg2 = selectRegion()
reg3 = selectRegion()

if reg1.exists() or reg2.exists():
    reg3.click()

if you have adapted your script to the region concept, you might implement the 
relative positioning concept:
ref = find("some-fixed-visual-object.png") # e.g. a logo or header 
reg1 = Region(ref.x+x1, ref.y+y1, w, h)

where you have to evaluate the x1 and y1 somehow (see faq 1686)

to define regions base on existing regions/matches:
http://doc.sikuli.org/region.html#extending-a-region

these faqs might have additional tips:
faq 1731
faq 1607
and even more

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

Reply via email to