← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #661603]: Set tolerance in click(image)

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
exists is the same as find, but does not stop with FindFailed in case of
not found.

while true
    my_image = exists(Pattern("1513067174539.png").similar(0.5))
    if my_image:
        click(my_image)
    else:
        sleep(5)
        type("t", KeyModifier.CTRL)

BTW: already know the docs
http://sikulix-2014.readthedocs.io/en/latest/index.html

alternatively:
while true
    if exists(Pattern("1513067174539.png").similar(0.5)):
        click()
       # click(getLastMatch()) #with versions before 1.1.1
    else:
        sleep(5)
        type("t", KeyModifier.CTRL)

one more thing:
Your loop runs forever.
So it is only interruptible by brute force.
think about integrating some leave condition
if someCondition:
    break
see faq 1437

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.