获取光标的 x,y 坐标的程序?

Cli*_*ote 5 display screen-capture windows-xp coordinates

是否有程序可以让您轻松获取光标的 x,y 坐标?

基本上,我将光标移动到屏幕上的某个位置,它会向我显示 x、y 坐标,并且可以选择将它们复制到剪贴板或以某种方式导出它们。

如果我截取屏幕截图并在 MS Paint 中打开它,我已经可以做到这一点,然后当我将鼠标光标移到屏幕截图上时,它会在状态栏中显示坐标,但是我必须手动写下它们,因此不方便。

use*_*686 4

Pegtop 的PMeter可以做到这一点。

它还有一个标尺和一个颜色选择器:

(这里有截图)


通过编程方式,这是使用GetCursorPos()Win32 API 或Control.MousePosition在 .NET 中完成的。

换句话说,现在是自己动手的时间。将此复制到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);
        }           
    }
}
Run Code Online (Sandbox Code Playgroud)

如果您有 .NET Framework,请使用以下命令进行编译:

csc MousePos.cs /r:System.dll /r:System.Windows.Forms.dll /r:System.Drawing.dll
Run Code Online (Sandbox Code Playgroud)

复制到剪贴板:

mousepos /c
Run Code Online (Sandbox Code Playgroud)

C# 编译器csc.exe可以在中找到C:\Windows\Microsoft.NET\Framework\v3.5(版本可能有所不同;您可以使用您拥有的版本)。