如何通过低级鼠标回调方法从 lParam 获取鼠标光标坐标?

How to obtain mouse cursor coordinates from lParam from a low level mouse callback method?

问题标题本身几乎描述了我的总体问题。以下是我到目前为止所做的。

    // the event is registered as following 
     mouseProc = new CallWndRetProc(MouseProc); // get keys
     MouseProcHandle = SetWindowsHookEx(WH_MOUSE_LL, mouseProc, IntPtr.Zero, 0);

     // The callback method
     public static IntPtr MouseProc(int nCode, int wParam, IntPtr lParam)
    {            
        if (wParam == WM_LBUTTONUP && MouseProcHandle != IntPtr.Zero )                
        {

        }

        if (wParam == WM_MOUSEMOVE)
        {
          // Want to get mouse position here 
        }

        return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam);
    }

有可靠的方法获取鼠标位置吗?

代码示例将不胜感激 谢谢

根据codeguru forum and especially pinvoke.net you are looking probably for (pinvoke.net again):

[StructLayout(LayoutKind.Sequential)]
 public struct MSLLHOOKSTRUCT
 {
     public POINT pt;
     public int mouseData; // be careful, this must be ints, not uints (was wrong before I changed it...). regards, cmew.
     public int flags;
     public int time;
     public UIntPtr dwExtraInfo;
 }

当然,你总能得到当前坐标。这里有很多 on Whosebug.