← 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: Answered => Open

denywinarto is still having a problem:
I got an idea for restarting the script,
what if we add a code to run the same script if the bug occurs?
Is that possible?

Also, i've tried using second handler,
but i cant get the script to run properly, it wont run RegA..D
I've added RegF because it turns out there's another error for network connection problem,
it's same as RegE, it can come up anytime

Any idea where to put the second handler correctly?

type("d",KEY_WIN)
doubleClick(Pattern("1346049773218.png").similar(0.85))
RegA = Region(SCREEN)
RegB = Region(SCREEN)
RegC = Region(SCREEN)
RegD = Region(SCREEN)
RegE = Region(SCREEN)
RegF = Region(SCREEN)
def handler(e):
    global isImgA_or_ImgB_or_ImgC_or_ImgD
    isImgA_or_ImgB_or_ImgC_or_ImgD = True
RegA.onAppear(Pattern("XPBLauncherF.png").similar(0.81), handler)
RegB.onAppear(Pattern("ICIMuhunmaaf.png").similar(0.91), handler)
RegC.onAppear(Pattern("1346051181203.png").similar(0.89), handler)
RegD.onAppear(Pattern("1346049877203.png").similar(0.92), handler)
def handler2(e):
    global isImgE_or_ImgF
    isImgE_or_ImgF = True
RegE.onAppear("XPBLauncherG.png", handler2)
RegF.onAppear(Pattern("QondErrorRep.png").similar(0.88), handler2)
while True:
    RegE.observe(FOREVER,background=True)
    RegF.observe(FOREVER,background=True)
    isImgE_or_ImgF = False
    while not isImgE_or_ImgF:
        wait(1)
    RegE.stopObserver()
    RegF.stopObserver()    
    if RegE.exists("XPBLauncherG.png"):
        RegE.stopObserver()
        click(Pattern("OK.png").similar(0.86))
        import pointblank
    elif RegF.exists(Pattern("QondErrorRep.png").similar(0.88),0):
        click(Pattern("1345976311187.png").similar(0.92))
        RegF.stopObserver()
        import pointblank
        break
        exit
    while True:
        RegA.observe(FOREVER,background=True)
        RegB.observe(FOREVER,background=True)
        RegC.observe(FOREVER,background=True)
        RegD.observe(FOREVER,background=True)
        isImgA_or_ImgB_or_ImgC_or_ImgD = False
        while not isImgA_or_ImgB_or_ImgC_or_ImgD:
            wait(1)
        RegA.stopObserver()
        RegB.stopObserver()
        RegC.stopObserver()
        RegD.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
            exit
        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
            exit
        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
            exit

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