//https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644986(v=vs.85) private IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { User32_MouseHook.MouseMessages msg = (User32_MouseHook.MouseMessages)wParam; User32_MouseHook.MSLLHOOKSTRUCT hookStruct = (User32_MouseHook.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(User32_MouseHook.MSLLHOOKSTRUCT)); MouseEventArgs32 e = new MouseEventArgs32(msg, ref hookStruct); MessageUtil.BeginInvoke(() => OnMouseMessage(null, e)); } return(User32_MouseHook.CallNextHookEx(_hookID, nCode, wParam, lParam)); }