private int LLMouseProc(int nCode, IntPtr wParam, IntPtr lParam) { if (Imports.IsKeyDown(Keys.F12)) { return(MouseHook.CallNextHookEx(this.mousehookId, nCode, wParam, lParam)); } MouseHook.MSLLHOOKSTRUCT mSLLHOOKSTRUCT = (MouseHook.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MouseHook.MSLLHOOKSTRUCT)); try { if (this.mouseEvent((MouseEventID)((int)wParam), mSLLHOOKSTRUCT.pt.x, mSLLHOOKSTRUCT.pt.y)) { return(1); } } catch (Exception ex) { Console.WriteLine("Error in mousehook " + ex.Message); } return(MouseHook.CallNextHookEx(this.mousehookId, nCode, wParam, lParam)); }
public void Dispose() { MouseHook.UnhookWindowsHookEx(this.mousehookId); }
public MouseHook(MouseHook.MouseEvent callback) { this.mouseEvent = callback; this.LLHookProc = new MouseHook.HookProc(this.LLMouseProc); this.mousehookId = MouseHook.SetWindowsHookEx(14, this.LLHookProc, IntPtr.Zero, 0); }