← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #254030]: Exists

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
what version of Sikuli?

there should be no difference between find and exists:
Both return the match object if found.

But generally:
if you want to check the returned match with if (match != null), then you must use exists, since find will throw a FindFailed in case of not found.

If your intention is to click something if it is found then you might just use
click(some_image)

this is only one find operation, whereas with your version you have 2.
When using exists, then depending on Sikuli version, you can reference the last match in the given region:

if(null != screen.exists(some_image)) { click(screen.getLastMatch) } //
before version 1.0.1

if(null != screen.exists(some_image)) { screen.click() } // version
1.0.1+

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