private void ProcessMessage(Message m) { if (m.Msg != 0x0312) { return; } var id = (ushort)m.WParam; var hotkey = _hotkeys.FirstOrDefault(x => x.ID == id); if (hotkey == null) { return; } var key = KeyInterop.KeyFromVirtualKey(((int)m.LParam >> 16) & 0xFFFF); var modifiers = (ModifierKeys)((int)m.LParam & 0xFFFF); //var key = (Keys)(((int)m.LParam >> 16) & 0xFFFF); //var modifiers = (PInvoke.KeyModifiers)((int)m.LParam & 0xFFFF); if (hotkey.KeyCode != key) { _logger.Error($"Hotkey {hotkey.DebugString()} got pressed but key in message is {key}!"); return; } if (hotkey.KeyModifiers != modifiers) { _logger.Error($"Hotkey {hotkey.DebugString()} got pressed but modifiers are {modifiers}"); return; } HotkeyPress?.Invoke(hotkey); }
protected void OnKeyPressed(ushort id, Keys key, Modifiers modifier) { HotkeyPress?.Invoke(id, key, modifier); }
/// <summary> /// Called when the hot key is pressed. /// </summary> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected virtual void OnHotkeyPress(EventArgs e) { HotkeyPress?.Invoke(this, e); }