← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #680137]: repeat([waitTime]) how is this syntax with a region onchange?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
ok, admitted: It is indeed a bit complicated with no experience in
scripting/programming.

An observation is bound to a region, where the given events are expected. For the region you might specify one or more events.
The observation itself is started with observe/observeInBackground and simply is a loop with the steps:
- make a shot of the region
- cycle through the events and check, whether happened
  - if happend, run the given callback function and wait for its completion
- check wether the observation should pause or even stop

This means, the timing of the observations (shot and check) is completely in the observation loop.
The handler can only influence the behavior in case it is called (event happened): delay, one more, stop event check, stop observation.

Hope it helps a bit.

Your case is much easier, than you think:
def handler(event):
    event.stopObserver()

regNumber.onChange(handler)
regNumber.observe(100) # a time within that a change should happen
# the script waits here until the handler is called and stops the observation
wait(4) # delay the flashing
newNumber = regNumber.text()

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