GetCursorPos和Privilegies

时间:2018-06-11 19:14:08

标签: mouseevent cursor-position

我想知道使用这个getcursorpos脚本是否可以读取光标的实际/全局位置的坐标?如果是,如何使用它来显示标签上的坐标?如果没有,适当的命令是什么?谢谢

        [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    internal static extern bool GetCursorPos(ref Win32Point pt);

    [StructLayout(LayoutKind.Sequential)]
    internal struct Win32Point
    {
        public Int32 X;
        public Int32 Y;
    };
    public Point GetMousePosition()
    {
        Win32Point w32Mouse = new Win32Point();
        GetCursorPos(ref w32Mouse);
        return new Point(w32Mouse.X, w32Mouse.Y);
    }

0 个答案:

没有答案