← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #180457]: Region click + next point of region

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
to just click points on the screen, we have the Location objects, which
just have x and y coordinates.

There are some Region methods, that return such points:
Region.getCenter()
Match.getTarget()
Region.getTopLeft()
...

and we have offset operators for Locations:

m = find("some image.png")
aPoint = m.getCenter()
click(aPoint.below(100))

would click 100 pixels below the center of the match region (in fact the
region of the found image on the screen).

here is an example with the home page of amazon.com. there is a drop
down in the top left, where you select the search category.

# find the amazon logo
# the click point (target offset) was evaluated using IDE's preview
m = find(Pattern("amazon.png").targetOffset(204,25))
# this clicks on the drop down
click(m)
# this is the reference point for the list
ref = m.getTarget()
# each entry has height 16
dd = 16 
we hover over the first 5 entries
for i in range(5):
    hover(ref.below((i+1)*dd))
    wait(0.5)

# and this clicks the 10th entry
click(ref.below(10*dd))

you may download a running script at  http://dl.dropbox.com/u/42895525/dropdown.sikuli.zip
just unzip, open amazon.com in a browser and run the script.

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