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



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

    // 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论坛,特别是pinvoke.net,你可能正在寻找(pinvoke.net):

[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;
 }

当然,你总是可以得到当前坐标。在Stackoverflow上有很多。

相关内容

  • 没有找到相关文章

最新更新