- PointToScreen(Mouse.GetPosition(this));
- Win32 API GetCursorPos
用法:
[StructLayout(LayoutKind.Sequential)]
public struct POINTt
{
public int X;
public int Y;
public POINTt(int x, int y)
{
this.X = x;
this.Y = y;
}
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool GetCursorPos(out POINTt pt);
例子:
POINTt pp = new POINTt();
GetCursorPos(out pp);
Point p = new Point(pp.X, pp.Y);