← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #152605]: I am not able to match my pattern precisely

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
You captured the button in the enabled case.

It is found in disabled case with score 0.97 and in enabled case with
score 1.0.

So the following approach differentiates between enabled and disabled.

r = Region(<the toolbar>) # see comment

img = "fillbutton.png"

m = r.exists(img)
print "tool = ", m # for debug only
if not m:
   print "tool not found"; exit(1)

if m.getScore() > 0.99:
	print "tool enabled"
else:
	print "tool disabled"

-- comment
For such mission critical decisions, it is vital, to restrict the search region as narrow as possible. In this case it should be the region occupied by the relevant part of the toolbar. Such a region can usually be evaluated from the application windows region:

r = App("your app").window().above(1).below(25).below(50)

from the upper border of app window (above(1)) we skip the title bar
(below(25)) and select the tool bar (below(50)). The numbers might have
to be adapted to your situation.

BTW: in my test, I did not have any problem to find the button in the
enabled case with Pattern("fillbutton.png").similar(1)

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