简体   繁体   中英

Sikuli 1.1 observe behaviour

I am new to create code. I try using Sikuli with observe function. When I use the script it does the thing one time and then never again.

while(1):
def Handler(event):
    stopObserver
    click(image)
    event.repeat(1)       
    pass

    while(1):
        onAppear("image", Handler)
        observe(FOREVER)

What is wrong with the script? Why does the script only click the image one time. If the image appears a second time nothing happens.

Observer in Sikuli can be a bit confusing at times.

Generally, you register one or more events to be observed with a Region using onXXXXX (observe-events or just events). Then you start the observation in a Region by starting its observer and later stopping it again as needed.

However, if you do not need the observer run in the background while you continue interacting with other areas of your screen, in most cases it would be easier to use timed wait . You can do it like this:

wait(pattern, waitTime)

Here the wait will only last for waitTime before the script flow continues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM