← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #206657]: Wait for image A or B or C forever, then take action accordingly

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- Java 7
... surely it will be compatible some day in the future, but I cannot tell you when (I am not the developer)

--- break; exit
Because of the nature of the break (jumps out of the loop to the next statement after the loop) a following exit will never be executed. So it can just be deleted.

--- Basically i want it to repeat the script whenever it crashes and found a bug when the program is running,
Not clear, what you are talking about.
Currently all the workflow containing action statements is repeated for ever, until one of the images appears. then the script stops (because of the break statements,that end the loop).
... and the RegE.stopObserver() is misplaced, must be in the block with the others.

If you mean, that only in the case of RegE the loop should be repeated
and in all other cases should stop:

# ...
    RegA.stopObserver()
    RegB.stopObserver()
    RegC.stopObserver()
    RegD.stopObserver()
    RegE.stopObserver()
    if RegA.exists(Pattern("XPBLauncherF.png").similar(0.81),0):
        click(Pattern("OK.png").similar(0.86))
        break
        exit
    elif RegB.exists(Pattern("ICIMuhunmaaf.png").similar(0.91),0):
        click(Pattern("OK.png").similar(0.86))
        break
    elif RegC.exists(Pattern("1346051181203.png").similar(0.89),0):
        doubleClick(Pattern("1346051181203.png").similar(0.89))
        wait(Pattern("1346088182875.png").similar(0.79), FOREVER)
        click(Pattern("Y.png").similar(0.83))
        click(Pattern("1346050299265.png").similar(0.83))
        break
    elif RegD.exists(Pattern("1346049877203.png").similar(0.92),0):
        click(Pattern("Y.png").similar(0.83))
        click(Pattern("1346050299265.png").similar(0.83))
        break
    elif RegE.exists(Pattern("ErrorReport.png").similar(0.88),0):
        click(Pattern("Dontsend.png").similar(0.92))
        wait(2) #whatever makes sense and repeat the loop now

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