Saturday, 30 September 2017

windows xp - Program for getting the cursor's x,y coordinates?



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.



Answer



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).


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...