sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #11147
Re: [Question #200323]: How to handle state of a particular image?
Question #200323 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200323
Status: Open => Answered
RaiMan proposed the following answer:
The only way to distinguish images, that are found at the same location,
but with different color/brightness/contrast/... is to use the
similarity.
To find the right distinguishing threshold, just make some tests this
way:
r = selectRegion() # the region where one of the buttons is visible
print r.find("enabled.png")
print r.find("disabled.png")
repeat this with 2 regions one containing a disabled and on an enabled
button.
The printout will tell you the similarity values.
Looking at these values you can decide, wether it is better to use
"enabled.png" or "disabled.png" for searching.
Then you can either use a Pattern().similar(0.95) (as an example) with
the exists() method, to make a decision
match = exists(Pattern(image).similar(0.75) # the minimum similarity
that finds both
and the check the resulting similarity with e.g.
sim = match.getSimilarity()
if sim > 0.95:
print "enabled"
else:
print "disabled"
The last method is very suitable together with findAll().
All the above code has to be adapted to your situation.
General recommendation: When dealing with such situations it is always
easier to divide the click into two operations:
instead of
click("image.png")
use
m = exists(some image or pattern)
if m: click(m)
else: print "we have a problem"
This gives you more options to script something useful.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.