HowTo search and click a fading image

Asked by Full Name

Sorry if this question is stupid I am not programming savvy in any way and I just try to write simple scripts. I browsed around and didn't find an answer.

I want to click on a fading image that could be anywhere on the screen. The simple solution is to use

if exists(image)
    click(image)

However, since the image is fading sometimes the image passes the similarity threshold between the "if exists(image)" and "click(image)", resulting in a Find Failed error. Since I don't know where the icon is I can't use

if Region.exists(image)
    click(Region)

either.
Is there an easy way to click exactly where an image was found when you don't know where the image will be?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- solution:
if exists(image)
    click()

--- background
exists() searches the screen.
click() without specifying a region (like: someReg.click()) simply clicks the last match of the given region, which is the screen in this case.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

... and another option:

try:
    click(image)
except:
    pass #do nothing if not found

Can you help with this problem?

Provide an answer of your own, or ask Full Name for more information if necessary.

To post a message you must log in.