← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #189702]: Distinguishing between Active and Grey text

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
This is one of the more tricky things in Sikuli.

The only chance, to solve this, is to use the similarity score (but
might not always work).

And in some cases it is necessary to narrow the region to the area,
where you expect the image to be, to avoid false positives.

In the case of active/inactive buttons/menu entries, take an image of
the active version ("active-img.png") and try:

if exists("active-img.png").similar(0.99): # do not use 1.0 or exact() - buggy
    print "should be the active one"
    click(getLastMatch()) # and click it
    # other follow up actions
else:
    print "nothing to do"

If your challenge is more complex (both variants have to be used with a
search), you can normally assume, that a correct match has a similarity
score above 0.95 and a false positive a score below 0.95

You might run some tests like:
print exists("active-img.png")
print exists("inactive-img.png")

in the different situations to find out the threshold.

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