Using repeat in event handle with wait time

Asked by Padam Jain on 2020-07-01

Hi,
I am using Siklulix 2.0.4 on windows 10.
I have registerd an onAppear event for a region. In the event handle i am trying to pause the observation for 5 seconds like below :

def changed(event):
    print("Region appeared")
    region.click(Pattern("Regionimage.png").targetOffset(270,62))
    print("Region closed.")
    event.repeat(5)

I observed that the event is running all the time, its not paused for 5 seconds. and because of this my further steps are not executing or they are executing with huge delay.

Any advises, if i am doing something wrong. my concern is that the wait time not working fine here.

Thanks .

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2020-07-01
Last reply:
2020-07-04
masuo (masuo-ohara) said : #1

I am interested in your question, so I tested in my environment.
"repeat" work fine in my environment.
Did you use "observeInBackground" ?

[my environment:]
Windows10, SikuliX2.0.4

[my sample code:]
def change(event):
    event.getRegion().highlight(1)
    event.repeat(5)

r = Region(0,0,100,800)
r.onAppear("1593845349130.png",change)
r.observeInBackground()

for cnt in range(30):
    if r.exists("1593844143835.png",0):
        r.stopObserver()
    else:
        Do.popup("cnt:%d" % cnt, "title", 1)

Can you help with this problem?

Provide an answer of your own, or ask Padam Jain for more information if necessary.

To post a message you must log in.