c#获取光标在屏幕中位置
需要调用win32api,winform、wpf通用
代码如下:
1 [DllImport("user32.dll")] 2 public static extern bool GetCursorPos(out POINT lpPoint); 3 4 [StructLayout(LayoutKind.Sequential)] 5 public struct POINT 6 { 7 public int X; 8 public int Y; 9 public POINT(int x, int y) 10 { 11 this.X = x; 12 this.Y = y; 13 } 14 }