← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #662733]: stop a reg.observeInBackground(FOREVER) whitout event happening

 

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

RaiMan proposed the following answer:
tested with 1.1.2.

this works:

img = "img.png"

def handler(event):
  event.stopObserver()

onAppear(img, handler)
SCREEN.observeInBackground(FOREVER)

while True:
  wait(1)
  m = Mouse.at()
  if (m.x < 100 and m.y < 100): # condition 1
    SCREEN.stopObserver()
    wait(1)
  if not SCREEN.isObserving(): # condition 2
    break

- when the image gets visible, the script ends due to the stop in the
handler and then condition 2

- when the image stays invisible after some time I move the mouse to top
left corner of screen, which fires condition 1 and stops the observing
and then the script ends due to condition 2

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