5

Is there a program which lets you easily get the x,y coordinates for your cursor?

Basically, I move my cursor to somewhere on my screen, it shows me the x,y coordinates and has an option to copy them to the clipboard or export them somehow.

I can already do this if I take a screenshot and open it in MS Paint, then as I move the mouse cursor over the screenshot it shows the coordinates in the status bar, however I have to manually write them down, hence its not convenient.

4
  • You might clarify this by specifying OS, and do you mean terminal coordinates, or GUI coordinates, and whether relative to window or screen. But, most GUI test recording tools can do that.
    – Keith
    Feb 10, 2011 at 22:45
  • @Keith I'm on windows XP, and I'm not sure what the difference is Feb 10, 2011 at 22:46
  • You may also want to look at this. Feb 11, 2011 at 6:06
  • 3
    See also Utilities for finding x/y screen coordinates with 6 answers, some for Windows.
    – slothbear
    Dec 25, 2012 at 4:45

1 Answer 1

4

Pegtop's PMeter can do this.

It also has a ruler and a color picker:

(here be screenshots)


Programmatically, this is done using GetCursorPos() Win32 API, or Control.MousePosition in .NET.

In other words, it's do-it-yourself time. Copy this to MousePos.cs:

using System;
using System.Drawing;
using System.Windows.Forms;

class Coords {
    [STAThread]
    static void Main(string[] args) {
        bool copy = (args.Length == 1 && String.Compare(args[0], "/c") == 0);
        Point point = Control.MousePosition;
        string pos = String.Format("{0}x{1}", point.X, point.Y);
        if (copy) {
            Clipboard.SetText(pos);
        } else {
            Console.WriteLine(pos);
        }           
    }
}

If you have .NET Framework, compile with:

csc MousePos.cs /r:System.dll /r:System.Windows.Forms.dll /r:System.Drawing.dll

Copy to clipboard:

mousepos /c

The C# compiler, csc.exe, can be found in C:\Windows\Microsoft.NET\Framework\v3.5 (the version may vary; you can use whichever you have).

3
  • It only seems to show the coordinates, but doesn't have any way to copy them? I'd like something that can copy the coordinates Feb 10, 2011 at 22:56
  • 1
    Wow that picture is really confusing... for lesser mortals. Someone else told me it was (they are a "Lesser Mortal"), so I assume it should be (for them). Feb 11, 2011 at 6:04
  • @Click: See update. Feb 11, 2011 at 6:05

Not the answer you're looking for? Browse other questions tagged .