← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #156967]: How do determine the x & y coordinates

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Not really clear what you mean :-(

--- 1st guess:
All Region and Match objects know their position on the screen. 
Their x and y (the regions upper left corner) can be either printed in the message area
print find("some-img.png")
prints something like that:
Match[10,176 340x45] score=1,00, target=center 

or can be extracted
m = find("some-img.png")
print "x-value =", m.x
print "x-value =", m.y
prints something like that:
x-value = 10 
y-value = 176

since x and y are numbers, you can calculate with them:
click(Location(m.x+100, m.y+100)
logs something like that:
[log] CLICK on (110,276)

--- 2nd guess
you see something on the screen and want to no a (x,y) pixel position to e.g. calculate an offset or width/height.

Most screen capture tools show pixel information while capturing or
preparing it.

If you do not have one of these, you can use Sikuli script also:

-- 1st possibility:
run this command in a new tab in the IDE:
print selectRegion()
and select something on the screen that makes sense for you
It prints something like that:
Region[119,176 147x69]@Screen(0) E:Y, T:3,0

-- 2nd possibility (more accurate)
put this command in a new tab in the IDE:
print Env.getMouseLocation()

the usage is a bit more complicated, since you cannot use the mouse ;-)
-- make visible on the screen, what you are interested on
-- move the mouse to the point of interest
-- go back to Sikuli IDE using the keyboard (ctrl-tab on windows, cmd-tab on Mac)
-- press ctrl-R/cmd-R to run the script
It prints something like that:
(117,128)
which is your (x,y)

Hope it helps.

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