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 override void OnEnable() { this.bounds = new Rect(0, 0, 256, 32); this.CreateButtons(); this.hook = new MouseHook(new MouseHook.MouseEvent(this.OnMouseEvent)); }
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); }