← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #239839]: Event based execution of script

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
To differentiate between a button being enabled/disabled, usually it is
sufficient to use:

if exists(Pattern(image_enabled_button).exact():
     print "enabled"
else:
     print "disabled"

This works in situations, where you are sure, that the button is visible
at all in one of the 2 states.

In your case (supposing, the button is always in the same place):

option 1:
button = Pattern("img1").exact()
while button.exists(Pattern("img1").exact()):
   wait(1)
print "Test Done"
type(Key.F4,KEY_ALT)

option 2:
button = Pattern("img1").exact()
button.waitVanish(Pattern("img1").exact(), 30)
print "Test Done"
type(Key.F4,KEY_ALT)

In both cases we only look in the region of the button, wether it is still found with a similarity of >0.99.
If the button gets disabled, it produces a similarity of <0.99 and hence is no longer found.

The first version has more flexibility, to handle special situations.

The second version will produce a FindFailed, if the button is visible
longer than 30 seconds and uses more cpu (3 searches per second vs. 1
per second with option 1)

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