Simple function to wait for an image before clicking

Asked by Shivaram Panchagnula on 2017-03-17

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:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Roman Podolyan
Solved:
2017-03-19
Last query:
2017-03-19
Last reply:
2017-03-18

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.

Thanks Roman Podolyan, that solved my question.