← Back to team overview

sikuli-driver team mailing list archive

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

 

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

Hi, im trying to create an script for game launchers, 
there are 3 possibilities when the launcher is clicked.
So sikuli needs to wait until image A or B or C forever,
then take action according to which image shows up, e.g:
imgA appears, click a
imgB appears, click b
imgC appears, click c

ive tried modifying the script from here :
https://answers.launchpad.net/sikuli/+question/195347


def handler(e):
    global isImgA_or_ImgB_or_ImgC
    isImgA_or_ImgB_or_ImgC = True

RegA.onAppear(imgA, handler)
RegB.onAppear(imgB, handler)
RegC.onAppear(imgC, handler)

while True:
    RegA.observe(FOREVER, background=True)
    RegB.observe(FOREVER, background=True)
    RegC.observe(FOREVER, background=True)
    isImgA_or_ImgB_or_ImgC = False
    while not isImgA_or_ImgB_or_ImgC:
        wait(1)
    RegA.stopObserver()
    RegB.stopObserver()
    RegC.stopObserver()
         if exists (imgA):
             click (imgA)
         elif exists (imgB):
             click (imgB)
         else:
             click (imgC)


But i cant get this to work, any idea why?
thanks

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