private CallNextHookEx ( IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam ) : IntPtr | ||
hhk | IntPtr | |
nCode | int | |
wParam | IntPtr | |
lParam | IntPtr | |
return | IntPtr |
IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { Bpr.BeepOk(); //tb3.Text = string.Format("{0} {1}", nCode, wParam); if (nCode >= 0) { if (wParam == (IntPtr)InterceptKeys.WM_KEYDOWN) { int vkCode = Marshal.ReadInt32(lParam); tb3.Text = $"{nCode} {wParam} {vkCode} DN"; Debug.WriteLine(/*(Keys)*/ vkCode, "DN >>>>>>"); } else if (wParam == (IntPtr)InterceptKeys.WM_KEYUP) { int vkCode = Marshal.ReadInt32(lParam); tb4.Text = $"{nCode} {wParam} {vkCode} UP"; Debug.WriteLine(/*(Keys)*/ vkCode, "UP >>>>>>"); } } KeyDown += (s, e) => { if (e.Key == Key.Escape) { Close(); /* messes up Cancel on save: App.Current.Shutdown();*/ } e.Handled = true; }; //tu: MouseLeftButtonDown += (s, e) => { DragMove(); e.Handled = true; }; return(InterceptKeys.CallNextHookEx(InterceptKeys._hookID, nCode, wParam, lParam)); }
private IntPtr HookCallbackInner(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam == (IntPtr)InterceptKeys.WM_KEYDOWN) { int vkCode = Marshal.ReadInt32(lParam); if (KeyDown != null) { KeyDown(this, new RawKeyEventArgs(vkCode, false)); } } else if (wParam == (IntPtr)InterceptKeys.WM_KEYUP) { int vkCode = Marshal.ReadInt32(lParam); if (KeyUp != null) { KeyUp(this, new RawKeyEventArgs(vkCode, false)); } } } return(InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam)); }
IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam == (IntPtr)InterceptKeys.WM_KEYDOWN) { int vkCode = Marshal.ReadInt32(lParam); // tb3.Text = string.Format("{0} {1} {2} DN", nCode, wParam, vkCode); } else if (wParam == (IntPtr)InterceptKeys.WM_KEYUP) { if (Marshal.ReadInt32(lParam) == 179) { var vm = (DdjViewModel)DataContext; if (vm.TglPlayPausACmd.CanExecute(null)) { vm.TglPlayPauseCmd.Execute(null); } } } } PreviewKeyUp += (s, e) => { if (e.Key == Key.Escape) { Close(); /* messes up Cancel on save: App.Current.Shutdown();*/ } e.Handled = true; }; //tu: !KeyDown - blocks all keystrokes!!!!!!! ...probably because of e.Handled = true; MouseLeftButtonDown += (s, e) => { DragMove(); e.Handled = true; }; return(InterceptKeys.CallNextHookEx(InterceptKeys._hookID, nCode, wParam, lParam)); }
private static IntPtr HookCallbackInner(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam == (IntPtr)InterceptKeys.WM_KEYDOWN || wParam == (IntPtr)InterceptKeys.WM_KEYUP) { KeyEvent?.Invoke(KeyInterop.KeyFromVirtualKey(Marshal.ReadInt32(lParam)), wParam == (IntPtr)InterceptKeys.WM_KEYDOWN); } } return(InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam)); }
private IntPtr HookCallback( int nCode, IntPtr wParam, IntPtr lParam) { try { return(HookCallbackInner(nCode, wParam, lParam)); } catch { Console.WriteLine("There was some error somewhere..."); } return(InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam)); }
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { try { return(HookCallbackInner(nCode, wParam, lParam)); } catch { Debugger.Break(); } return(InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam)); }
public static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { bool alt = (Control.ModifierKeys & Keys.Alt) != 0; bool control = (Control.ModifierKeys & Keys.Control) != 0; int vkCode = Marshal.ReadInt32(lParam); Keys key = (Keys)vkCode; if (alt && key == Keys.F4) { Application.Exit(); return((IntPtr)1); // Handled. } if (!AllowKeyboardInput(alt, control, key)) { return((IntPtr)1); // Handled. } } return(InterceptKeys.CallNextHookEx(_hookID, nCode, wParam, lParam)); }
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { return(InterceptKeys.CallNextHookEx(_hookID, nCode, wParam, lParam)); }