← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #147413]: how to use onAppear in a region

 

Question #147413 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/147413

    Status: Open => Answered

RaiMan proposed the following answer:
you got it --- nearly ;-)

the onAppear is bound to a Region, but the observe() is bound to SCREEN
(the default region).

optimized and corrected:

def myHandler(event):
        popup(" it") # popup() does not return anything / pass only necessary if otherwise not any code in the def()

reg = Region(226,90,350,105)
reg.onAppear(image1 , myHandler)
reg.observe(5)

when the script reaches observe(5) it stops running for 5 seconds.
during this time the onAppear() event is watched out in the Region reg.
if it happens, during this 5 seconds, the popup should come up.

you might use with:

reg = Region(226,90,350,105)
with reg:
    onAppear(image1 , myHandler)
    observe(5)

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