I have an application that needs the user to enter the x and y location of a couple of items on the screen. [Yes, this is crap and I'll replace it, but for now...]
On Mac OS X, I'm using Snapz Pro X. When I choose to take a snap of a selection, the interface displays the mouse cursor location. This is OK for my personal use, but I can't ask users to buy a $69 program for this function.
I thought I had a solution with the built-in program "Grab", but it reports the coordinates from the bottom left, and I need it from the top left.
I don't have access to Windows; not sure what to use there. I've not even been able to come up with good search terms since mouse and coordinates and x/y are so common. Ideas are welcome there. Extra credit: same x/y finder for Linux. A Java program would be OK too, since the main application is in Java.
512 Answers
For Windows you can use Point Position :
The way to use the application is very simple:
- Move the window by putting your mouse cursor in the cross which is in the middle of it, and point one of the four corner arrows into the place of the screen you want to define.
- Then push the button corresponding to the pointing arrow.
- The text entries will take the color of the button, and they will show you the exact pointing position.
Point Position (for Windows) is a simple tool that lets you pick the coordinates for any point on your screen (using X,Y axis). Simply point one of the four corner arrows at the spot on your screen that you want to define and click the button to display the X/Y coordinates.
Point Position is freeware.
6For Macintosh, use the built-in screen capture function. Press Command-Shift-4 to take a picture of part of the screen. The cursor switches to a crosshairs cursor that includes the x/y screen coordinates. Press ESC to cancel the operation
1I was led to this page through a query of my own. I had a further search around and found xev (on Linux and Mac OS X.)
Here's the Mac OS X documentation:
The Bash commands
$ root=`xwininfo -root | grep xwininfo | sed 's/.*0x/0x/; s/ .*//'`
$ xev -id $rootprovided me with the information required. :)
1I used Cursor Position from CNET.com:
5From Mattlav Software: Cursor Position allows you to work out the exact X and Y position of your cursor even as you move it, it also tells you how many pixels you have gone across if you move the cursor with the application open.
For windows, you can use a powershell script with System.Windows.Forms.Cursor
e.g.
Add-Type -AssemblyName System.Windows.Forms
while (1) { $X = [System.Windows.Forms.Cursor]::Position.X $Y = [System.Windows.Forms.Cursor]::Position.Y Write-Host -NoNewline "`rX: $X | Y: $Y"
}(copied and modified from )
For Mac OS X, xScope is pretty good. Turn on the Loupe (magnify) tool to make it easier to see exactly where you are. Then use the Crosshair tool to locate the exact spot you need.
If you'd like to measure your spot from a place that is not relative to the screen origin, move the cursor to your local 0,0, then press Command-0 to set that spot as 0,0.
xScope is a commercial product from The iconfactory. The app shows up in bundles regularly. But it must be worthwhile. Heck, the latest version boasts
170+ new features
As of this writing (2022), the links were dead for both Point Position and Cursor Position, but I found a similar program called MPos on SourceForge. Just run the executable and you get a draggable display showing the current mouse coordinates.
For Java, you can use the PointerInfo class, introduced in Java 1.5.
import java.awt.MouseInfo;
import java.awt.Point;
public class Portia { public static void main(String args[]) throws InterruptedException { Thread.sleep(10000); // some time for user to position mouse Point spot = MouseInfo.getPointerInfo().getLocation(); System.out.println( String.valueOf(spot.getX()) +","+ String.valueOf(spot.getY())); }
} Skitch from Evernote includes an x/y coordinate display while taking a screen snap. The numbers are small and don't have any contrast layer -- so they're hard to see on a black background. Skitch is currently free.
Quix App is a browser bookmarklet: cross-platform, no plug-ins.
Drag the bookmarklet to your bookmarks toolbar. Click. Enter the command ruler, and you get a nice cross-hairs cursor to work with, and an informative pop-up with all the coordinates.
If you're using the Chrome browser, there is a well-maintained extension called coordinates. It shows coordinates for the page, the screen, and can measure an area by dragging.