How do I get Observe to pause?

Asked by David

I have a script that is working in every way but I can't get Observe() to pause or end and restart while actions take place.

I am waiting for a change onscreen to occur. When it does, It fires off the ClickVideo() event. This event also changes the screen briefly. So I need Observer to stop, for about 5 seconds, while this happens then start up again.

I tried using wait(5) in several key spots, but this wasn't pausing Observe(). I then added a stopObserver() in a couple of places but couldn't get that to work.

Can you tell me what I am doing wrong?

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
    while exists("1470276113431.png"):
        if B1.exists("1470266612550.png"):
            B2.click()
        if B2.exists("1470266612550.png"):
            B3.click()
        if B3.exists("1470266612550.png"):
            B4.click()
        if B4.exists("1470266612550.png"):
            click("1470275832696.png")
            wait(3)
            B1.click()
    if not exists("1470276653899.png"):
        #start next set
        vSet = vSet + 1
        ClickSet()
        B1.click()
    wait(5)
    if exists("1469490503735.png"):
        Watched = Watched - 1
        ClickVideo()

while Watched <= 500:
    wait(5)
    #watch for change in status
    R1.onChange(50, ClickVideo)
    R1.observe()

Please and Thank You

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
David
Solved:
Last query:
Last reply:
Revision history for this message
David (davper) said :
#1

I found my problem. I had a while when I should have had an if exists