← Back to team overview

sikuli-driver team mailing list archive

[Question #323987]: Defined function is looping

 

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

Hi
I am having an issue that makes no sense to me. The defined function ClickVideo is looping. 

Yes, I do have a recursive call. But this is not where it is looping. I read on another post your comments about recursive calls. This call is only to address an error should one appear.

I added popups through out my code so I could follow it as it ran. So as it runs, this is the popups I am getting (9, 1, 2, (3,4,5, or 6), 11; 1, 2, (3,4,5, or 6), 11; 1, 2, (3,4,5, or 6), 11; etc.)
What I was expecting was (9, 1, 2, (3,4,5, or 6), 11; 9, 1, 2, (3,4,5, or 6), 11; etc.). After function runs, I am expecting it to go back to waiting for a change to region R1.

That says to me that my function is looping. Should I have a terminator on my function?



R1 = find(Pattern("1470246838908.png").similar(0.90))
R2 = find("1470253780841.png")
B1 = Region(R2.x+21, R2.y+18, 72, 77)
B2 = Region(R2.x+104, R2.y+18, 72, 77)
B3 = Region(R2.x+190, R2.y+18, 72, 77)
B4 = Region(R2.x+273, R2.y+18, 72, 77)
Watched = 0
vSet = 1

# Change video set
def ClickSet(event):
    global vSets
    if vSets == 2:
        click("1470278088532.png")
    if vSets == 3:
        click("1470278122703.png")
    if vSets == 4:
        click("1470278147590.png")
    if vSets == 5:
        click("1470278175919.png")
    if vSets == 6:
        click("1470278203403.png")
    wait(5)
    
# Click next video
def ClickVideo(event):
#    R1.stopObserver()
    global Watched
    Watched = Watched + 1
    popup("1")
    if exists("1470276113431.png"):
        popup("2")
        if B1.exists("1470266612550.png"):
            B2.click()
            popup("3")
        elif B2.exists("1470266612550.png"):
            B3.click()
            popup("4")
        elif B3.exists("1470266612550.png"):
            B4.click()
            popup("5")
        elif B4.exists("1470266612550.png"):
            click("1470275832696.png")
            wait(5)
            B1.click()
            popup("6")
        else: 
            popup("Nothing is playing now")
            exit()
    else:
        popup("7")
        #start next set
        vSet = vSet + 1
        ClickSet()
        B1.click()
    wait(5)
    popup("11")
    #if error appears play next video
    if exists("1469490503735.png"):
        Watched = Watched - 1
        popup("8")
        ClickVideo()

#Watch 500 videos
while Watched <= 500:
    popup("9")

    R1.onChange(50, ClickVideo)
    R1.observe()

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.