← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #167353]: click image onAppear in region

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
the usage

RegionImg.onAppear(img, click(img))

is not according to the feature definition of observe()

look: http://sikuli.org/docx/region.html#observing-visual-events-
in-a-region

You have to move the click() action to the event handler function that
has to be specified as the second parameter of onXXX() and onXXX() and
observe() have to use the same region object.

your case e.g.:

with Region(437,419,687,303):
    onAppear(img, handler)
    observe(25)

But why not simply use:

with Region(437,419,687,303):
    wait(img, 25)
    click(getLastMatch())

so you do not need the complex construct of observe().

If you want to handle the notFound error, you might use exists() instead
of wait():

with Region(437,419,687,303):
    if not exists(img, 25):
        print img, "not Found"
        exit(1)
    click(getLastMatch())

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