Simple function to wait for an image before clicking

Asked by Shivaram Panchagnula

Hi,

I am new to Sikuli and Python.
I am trying to automate a set of images that appear on the screen.
I would like to create a simple function that would wait for a particular image till it appears on the screen and then click once it appears. This way, it should work on any machine irrespective of the loading speed as it waits till the image appears.

Please help me out with this function

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Roman Podolyan
Solved:
Last query:
Last reply:
Revision history for this message
Best Roman Podolyan (podolyan-roman) said :
#1

Function code (tested):
_______
def wait_and_click(my_image, time):
    wait(my_image, time)
    click(getLastMatch())
______

"time" is in seconds.

Help chapter about wait() and other functions ready-available: http://doc.sikuli.org/region.html#Region.wait

But be informed that Sikuli may not find _any_ image on _any_ machine, different machines display resolutions and DPI must match.

Revision history for this message
Shivaram Panchagnula (shivaram) said :
#2

Thanks Roman Podolyan, that solved my question.