private static int MouseHookProc(int nCode, int wParam, IntPtr lParam) { int result; if (nCode >= 0) { HookManager.MouseLLHookStruct mouseLLHookStruct = (HookManager.MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(HookManager.MouseLLHookStruct)); MouseButtons buttons = MouseButtons.None; short num = 0; int num2 = 0; bool flag = false; bool flag2 = false; switch (wParam) { case 513: flag = true; buttons = MouseButtons.Left; num2 = 1; break; case 514: flag2 = true; buttons = MouseButtons.Left; num2 = 1; break; case 515: buttons = MouseButtons.Left; num2 = 2; break; case 516: flag = true; buttons = MouseButtons.Right; num2 = 1; break; case 517: flag2 = true; buttons = MouseButtons.Right; num2 = 1; break; case 518: buttons = MouseButtons.Right; num2 = 2; break; case 522: num = (short)(mouseLLHookStruct.MouseData >> 16 & 65535); break; } MouseEventExtArgs mouseEventExtArgs = new MouseEventExtArgs(buttons, num2, mouseLLHookStruct.Point.X, mouseLLHookStruct.Point.Y, (int)num); if (HookManager.s_MouseUp != null && flag2) { HookManager.s_MouseUp(null, mouseEventExtArgs); } if (HookManager.s_MouseDown != null && flag) { HookManager.s_MouseDown(null, mouseEventExtArgs); } if (HookManager.s_MouseClick != null && num2 > 0) { HookManager.s_MouseClick(null, mouseEventExtArgs); } if (HookManager.s_MouseClickExt != null && num2 > 0) { HookManager.s_MouseClickExt(null, mouseEventExtArgs); } if (HookManager.s_MouseDoubleClick != null && num2 == 2) { HookManager.s_MouseDoubleClick(null, mouseEventExtArgs); } if (HookManager.s_MouseWheel != null && num != 0) { HookManager.s_MouseWheel(null, mouseEventExtArgs); } if ((HookManager.s_MouseMove != null || HookManager.s_MouseMoveExt != null) && (HookManager.m_OldX != mouseLLHookStruct.Point.X || HookManager.m_OldY != mouseLLHookStruct.Point.Y)) { HookManager.m_OldX = mouseLLHookStruct.Point.X; HookManager.m_OldY = mouseLLHookStruct.Point.Y; if (HookManager.s_MouseMove != null) { HookManager.s_MouseMove(null, mouseEventExtArgs); } if (HookManager.s_MouseMoveExt != null) { HookManager.s_MouseMoveExt(null, mouseEventExtArgs); } } if (mouseEventExtArgs.Handled) { result = -1; return result; } } result = HookManager.CallNextHookEx(HookManager.s_MouseHookHandle, nCode, wParam, lParam); return result; }
private void HookManager_MouseMoveExt(object sender, MouseEventExtArgs e) { if (this.m_MouseMoveExt != null) { this.m_MouseMoveExt(this, e); } }