int MouseEvents(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) { return(Native.CallNextHookEx(_hook, code, wParam, lParam)); } if (code == this.hcAction) { // Left button pressed somewhere if (wParam.ToInt32() == (uint)Native.Message.WM_LBUTTONUP) { Native.MSLLHOOKSTRUCT ms = new Native.MSLLHOOKSTRUCT(); ms = (Native.MSLLHOOKSTRUCT)Marshal.PtrToStructure( lParam, typeof(Native.MSLLHOOKSTRUCT)); IntPtr win = Native.WindowFromPoint(ms.pt); string title = GetWindowTextRaw(win); if (LButtonUpClicked != null) { LButtonUpClicked( this, new SysMouseEventInfo { WindowTitle = title }); } } } return(Native.CallNextHookEx(_hook, code, wParam, lParam)); }
private static int HookProcedureCallback(int nCode, IntPtr wParam, IntPtr lParam) { RefreshSlideViewWindowHandle(); //Only process inputs that are sent to the main slide view window. if (!IsSlideViewWindowFocused()) { return(Native.CallNextHookEx(0, nCode, wParam, lParam)); } bool blockInput = false; if (nCode == 0) { int keyIndex = wParam.ToInt32(); if (_keyStatuses.ContainsKey(keyIndex)) { var keyStatus = _keyStatuses[keyIndex]; if (IsKeydownCommand(lParam)) { if (!keyStatus.IsPressed) { keyStatus.Press(); } foreach (var action in _keyDownActions[keyIndex]) { var block = action.RunConditionally(keyStatus); if (block) { blockInput = true; } } } else { if (keyStatus.IsPressed) { foreach (var action in _keyUpActions[keyIndex]) { var block = action.RunConditionally(keyStatus); if (block) { blockInput = true; } } keyStatus.Release(); } } } } if (blockInput) { return(1); } else { return(Native.CallNextHookEx(0, nCode, wParam, lParam)); } }
private static int HookProcedureCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam.ToInt32() == (int)Native.Message.WM_LBUTTONDBLCLK && !IsReEnteredCallback()) { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; FindSlideViewWindowHandle(handle); if (IsMouseWithinSlideViewWindow() && DoubleClick != null) { DoubleClick(selectedRange); } } // Left mouse button up/released if (wParam.ToInt32() == (uint)Native.Message.WM_LBUTTONUP) { LeftButtonUp?.Invoke(); } // Right mouse button down if (wParam.ToInt32() == (uint)Native.Message.WM_RBUTTONDOWN) { RightClickCoordinates = new Coordinates(Cursor.Position.X, Cursor.Position.Y); } UpdateStartTime(); } return(Native.CallNextHookEx(0, nCode, wParam, lParam)); }
private static int HookProcedureCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam.ToInt32() == (int)Native.Message.WM_LBUTTONDBLCLK && !IsReEnteredCallback()) { var handle = Process.GetCurrentProcess().MainWindowHandle; FindSlideViewWindowHandle(handle); if (IsMouseWithinSlideViewWindow() && DoubleClick != null) { DoubleClick(selectedRange); } } // Left mouse button up/released if (wParam.ToInt32() == (uint)Native.Message.WM_LBUTTONUP) { if (LeftButtonUp != null) { LeftButtonUp(); } } UpdateStartTime(); } return(Native.CallNextHookEx(0, nCode, wParam, lParam)); }