← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #242340]: How to handle when there are high similarity scores for enabled and disabled button Patterns?

 

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

RaiMan proposed the following answer:
Distinguishing between two button states is one of the more tricky
situations in Sikuli.

Generally you have to have optimised images of both button states (as little background as possible, concentrating on the unique aspects).
You have to be sure, that both images match their button state with a score of 1.0 and have a similar size.

for both buttons you now have to setup Patterns with similarity 0.99 (in IDE preview) or as
Pattern btnEnabled = new Pattern("btnEnabled.png").exact();
Pattern btnDisabled = new Pattern("btnDisabled.png").exact();

(exact() is the same as similar(0.99) and works correctly in version
1.0.1+)

In your case, this should work:

Screen s = new Screen();
if (s.exists(btnDisabled)) {
  s.getLastMatch().grow(10).wait(btnEnabled);
} else {
  s.wait(btnEnabled);
}

grow(10) assures, that there is some margin around the match region, so different image sizes are compensated.
I guess you know: wait() will give up after 3 seconds ;-)

This could be optimised, when it is possible to work in the region of
the button from the beginning.

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