sikuli code repeating

Asked by MJ

How can i have this code run up-to 10X when it finds what it is looking for it clicks and then terminates. I only want "the else" to click one time, but "if not exists" to continue up-to 10 times, before terminating.

for n in range(10):
#while (exists("1469038914742.png"),1):
#while True:
        if not exists("1469039051065.png"):
            click("1469038914742.png")
        else:
            click("1469042062223.png")
            click("1469038914742.png")

Thanks in advance

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
masuo (masuo-ohara) said :
#1

Use "break" when you want to exit from loop.

[example specification]
When image1 is found, click image3, then end.
While image1 is not found, repeat click image2 and sleep .

[example code]
for n in range(10):
    if not exists("image1.png",0):
         click("image2.png")
         sleep(1)
    else:
        click("image3.png")
        break

Can you help with this problem?

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

To post a message you must log in.