[Sikuli-driver] [Question #661603]: Set tolerance in click(image)

2017-12-11 Thread Max
New question #661603 on Sikuli:
https://answers.launchpad.net/sikuli/+question/661603

Hi,

I have a problem in my Sikuli python script and no idea how to solve it.

I need to click on an image, but this could slightly differ from one computer 
to another. My code now is something like this:

while (exit != 1):
count += 1 
if exists("1508670860035.png"):
click("150867092.png")
exit = 1
else:

I would like to say something like "if exists("1508670860035.png").similar(0.5) 
click ("1508670860035.png").similar(0.5)". 
So I would like to add sort of tolerance for this image, so it could not be 
exactly the same, but differ a little.

I tried to use similar() function but I think I used in a wrong way (my script 
crashed).

Any suggestion?

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

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


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

2017-12-11 Thread RaiMan
Question #661603 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/661603

Status: Open => Answered

RaiMan proposed the following answer:
have you already looked into the docs?
learn about using a Pattern instead of an image, to control wanted similarity.

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

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


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

2017-12-11 Thread RaiMan
Question #661603 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/661603

RaiMan proposed the following answer:
... but be aware:
lowering the wanted similarity to 0.5 increases the risk for false positives.
You might think of optimizing your shots (as little background as possible in 
most cases)
see: 
http://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen

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

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


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

2017-12-12 Thread Max
Question #661603 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/661603

Status: Answered => Open

Max is still having a problem:
thanks for the tips!

I was able to do it using pattern as you suggested with the following
code:

my_image = find(Pattern("1513067174539.png").similar(0.5))
click(my_image)

Then I tried to insert exsist function since I don't know a priori if
the image is present and I don't want that if the find fails the program
stops, but the script crashed.

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

How can I solve this problem? Is it possible to use a mach object
obtained by find() inside exsist()???

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

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


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

2017-12-12 Thread RaiMan
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.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


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

2017-12-12 Thread Max
Question #661603 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/661603

Status: Answered => Solved

Max confirmed that the question is solved:
Thanks RaiMan, that solved my question.

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

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp