← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #175717]: Need help! with find or skip

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
yes, the easiest solution: use exists() as mentioned in comment #1

on looping: faq 1437

while True:
    found = None
    if not exists(iron1):
        if exists(iron2):
            found = getLastMatch()
    else:
        found = getLastmatch()
    click(found)

this will:
- look for iron1
- look for iron2 if iron1 not found
- click on the one that was found (iron1 or iron2)
- do nothing if none found

and do all this repeatedly for ever.

You have to add appropriate waiting time in the exists() 2nd parameter
and decide, how you want to terminate (break) the loop.

example for a solution (stop loop if 3 times nothing found):

max = 3
while max > 0:
    found = None
    if not exists(iron1):
        if exists(iron2):
            found = getLastMatch()
    else:
        found = getLastmatch()
    if not found:
        max -= 1
    click(found)

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