public bool UnregisterHotKey(HotKeyModifiersEnum modifiers, InputKeyEnum key) { if (this.windowHandle != null) { int hotKeyID = this.GetHotKeyID(modifiers, key); if (this.registeredHotKeys.Contains(hotKeyID)) { this.registeredHotKeys.Remove(hotKeyID); return(UnregisterHotKey(this.windowHandle, hotKeyID)); } } return(false); }
public bool RegisterHotKey(HotKeyModifiersEnum modifiers, InputKeyEnum key) { if (this.windowHandle != null) { int hotKeyID = this.GetHotKeyID(modifiers, key); if (!this.registeredHotKeys.Contains(hotKeyID)) { this.registeredHotKeys.Add(hotKeyID); return(RegisterHotKey(this.windowHandle, hotKeyID, (uint)modifiers, (uint)this.ConvertScanCodeToVirtualKey(key))); } } return(false); }
public void KeyUp(InputKeyEnum key) { InputContainer input = new InputContainer { Type = INPUT_KEYBOARD }; input.Data.Keyboard = new KeyboardInput() { Scan = (ushort)key, Flags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE }; InputContainer[] inputs = new InputContainer[] { input }; uint result = SendInput(1, inputs, Marshal.SizeOf(typeof(InputContainer))); }
public void KeyUp(InputKeyEnum key) { InputContainer input = new InputContainer { Type = INPUT_KEYBOARD }; input.Data.Keyboard = new KeyboardInput() { Scan = (ushort)key, Flags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE }; if (key == InputKeyEnum.Up || key == InputKeyEnum.Down || key == InputKeyEnum.Left || key == InputKeyEnum.Right) { input.Data.Keyboard.Flags |= KEYEVENTF_EXTENDEDKEY; } InputContainer[] inputs = new InputContainer[] { input }; uint result = SendInput(1, inputs, Marshal.SizeOf(typeof(InputContainer))); }
private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { try { if (msg == WINDOWS_MESSAGE_HOTKEY) { int hotKeyID = wParam.ToInt32(); if (this.registeredHotKeys.Contains(hotKeyID)) { int virtualKey = (((int)lParam >> 16) & 0xFFFF); InputKeyEnum key = this.ConvertVirtualKeyToScanCode(virtualKey); HotKeyModifiersEnum modifiers = (HotKeyModifiersEnum)((int)lParam & 0xFFFF); this.HotKeyPressed?.Invoke(this, new HotKey(modifiers, key)); } } } catch (Exception ex) { Logger.Log(ex); } return(IntPtr.Zero); }
public HotKeyConfiguration(HotKeyModifiersEnum modifiers, InputKeyEnum key, Guid commandID) : base(modifiers, key) { this.CommandID = commandID; }
public HotKey(HotKeyModifiersEnum modifiers, InputKeyEnum key) { this.Modifiers = modifiers; this.Key = key; }
private int ConvertScanCodeToVirtualKey(InputKeyEnum key) { return(MapVirtualKey((uint)key, 3)); }
private int GetHotKeyID(HotKeyModifiersEnum modifiers, InputKeyEnum key) { return((this.ConvertScanCodeToVirtualKey(key) << 16) | (int)modifiers); }
public InputAction(InputKeyEnum key, InputActionTypeEnum actionType, bool shift, bool control, bool alt) : this(actionType, shift, control, alt) { this.Key = key; }