← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #688897]: Why Handler is not working in region.onAppear.?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
using r.observeInBackground makes only sense, if you want to wait for
something, that might appear/vanish/change in PARALLEL to your normal
workflow (some popup for example).

In your case you are simply waiting for "1581564293714.png" and if it
comes up, want to do something.

This is how one would do it normally:

while (1):
  if r.exists("1581564293714.png", 10): 
    r.doubleClick() # click last match
    while exists(Pattern("1581657244124.png").similar(0.85)):
      click() # click last match (I guess)
      #sleep(0.5) # not needed, next exists waits max 3 seconds anyways
    if exists("1582077186091.png"):
      click ()
      click("1582077240628.png")
    else:
      if exists("1582257077497.png"):
        click()
      else:
        click("1582257086061.png")            
        sleep(1)
      while exists(Pattern("1581657244124.png").similar(0.83)):
        click()

Be aware: while the handler is doing its job, the main workflow hangs
until the handler finishes its work. So it usually does not make sense,
to have longer running handlers.

Workflows like mine above are much easier to track anyways.

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