sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #32346
Re: [Question #266820]: onVanish not working on specific region
Question #266820 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/266820
Status: Open => Answered
RaiMan proposed the following answer:
I cannot really judge what you are doing there
... especially:
image = Image()
currentImageRegion = image.region()
... and the observe has to be for the same region as the defined
expected events:
onVanish(imageScreenShot, imageMoved) # THE CHANGED LINE
observe(background = True)
... works on the screen
currentImageRegion.onVanish(imageScreenShot, imageMoved) # THE CHANGED LINE
observe(background = True)
... do not fit together - different regions
... but I have tested, that this works:
switchApp("Safari")
# the image to vanish
img = "img.png"
if not exists(img): exit(1)
# the region, the image currently is inside
reg = Region(getLastMatch())
reg.highlight(1)
hasMoved = False
def moved(e):
global hasMoved
print "moved"
e.stopObserver()
hasMoved = True
Debug.on(3)
reg.onVanish(img, moved)
reg.observe(FOREVER, True)
while not hasMoved:
wait(1)
print "stopped"
when I now move the Safari widow, the handler is visited in that moment.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.