← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #169767]: IF image appears FIRST in 1 of the 2 regions

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Sorry, but this script now is complete rubbish.

regA, regB, imgA, imgB, isRegA, isRegB are variables, that have to be taken as is!
I am taking my first version and add the option, that we check for both images always and loop

regA = Region(x,y,w,h) # to be specified or evaluated somehow
regB = Region(x,y,w,h) # to be specified or evaluated somehow
imgA = "the captured image A you are waiting for.png" # here you should see the thumbnail!
imgB = "the captured image B you are waiting for.png"

while True: # now it loops for ever 
    isRegA = False
    isRegB = False
    while True:
        if regA.exists(imgA, 0): isRegA = True
        if regB.exists(imgB, 0): isRegB = True
        if isRegA or isRegB: break # one or both images appeared
        wait(5)

    if isRegA:
        print "running script for A"
    elif isRegB:
        print "running script for B"
    else:
        print "should never happen"
# this is the end of the main loop

To stop the loop, you have to either kill the IDE, or have somewhere in
the loop a statement like

if some_condition == True: break

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