← 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

denywinarto posted a new comment:
Yes, it's the one i asked about in other thread,
i used looping to solve this..

About the for-range method,
I couldn't figure out where to put it for the this code :

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)
RegG = 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_or_ImgG
    isImgE_or_ImgF_or_ImgG = True
RegE.onAppear("XPBLauncherG.png", handler2)
RegF.onAppear(Pattern("QondErrorRep.png").similar(0.88), handler2)
RegG.onAppear(Pattern("1346088182875.png").similar(0.79), handler2)
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
    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))
        while True:
            RegE.observe(FOREVER,background=True)
            RegF.observe(FOREVER,background=True)
            RegG.observe(FOREVER,background=True)
            isImgE_or_ImgF_or_ImgG = False
            while not isImgE_or_ImgF_or_ImgG:
                wait(1)
            RegE.stopObserver()
            RegF.stopObserver()
            RegG.stopObserver()
            if RegE.exists("XPBLauncherG.png"):
                click(Pattern("OK.png").similar(0.86))
                break
            elif RegF.exists(Pattern("QondErrorRep.png").similar(0.88),0):
                click(Pattern("1345976311187.png").similar(0.92))
                break
            elif RegG.exists(Pattern("1346088182875.png").similar(0.79)):
                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

That's why i used 2 scripts,
with the other one not having import,
so it's script A importing script loop_A

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