← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #151368]: What does this runtime error?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
especially in the beginning or when starting a new case, it helps to
store found regions for later use, use the slow motion mode and
Region.highlight() to see what happens.

--- storing things:

match1 = find("image1.png")
click(match1)

is the same as click("image1.png"), but now we have stored the region,
that image1 occupies on screen and can use it later on.

another possibility:

click("image1.png")
match = getLastMatch()

we get the same region, since every find operation stores the last
match.

--- using stored things to make new ones

Supposing we have found something and stored the match in match1. we
know that something else can be found in an area right of this object.
So we define this other area based on the thing we know: match1.

reg1 = match1.right().nearby(100) 
reg1.highlight(3) # watch the new region for 3 seconds

---- looking inside of regions

It is always a good idea, to restrict find operations to a smaller
region than the whole screen. This speeds up things and avoids finding
things you did not mean.

the blathering way - but more obvious:

match1 = find("image1.png")
click(match1)
reg1 = match1.right().nearby(100) 
reg1.highlight(3)
match2 = reg1.find("imagex.png") # searched only inside reg1
click(match2)

the compact form as it is defined in the API

click(match1)
getLastMatch().right().nearby(100).click("imagex.png") # currently buggy

but we have a bug in the moment with Region.click(), so you have to
write it this way:

click(match1)
click(getLastMatch().right().nearby(100).find("imagex.png")) 

Find your own way and have fun.

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