/// <summary> /// Initializes a new instance of the <see cref="Hotkey"/> class. /// </summary> /// <param name="hotkey">The hotkey in string format.</param> public Hotkey(string hotkey) { var hotkeyObj = HotkeyRepresentation.AsHotkey(hotkey); KeyCode = hotkeyObj.KeyCode; Modifiers = hotkeyObj.Modifiers; }
/// <summary> /// Overrides the default window message processing to detect the registered Hotkeys when pressed. /// </summary> /// <param name="m"></param> protected override void WndProc(ref Message m) { if (m.Msg == WM_HOTKEY) { var hotkey = HotkeyRepresentation.AsHotkey(this.Hotkeys[m.WParam.ToInt32()]); HotkeyPressed?.Invoke(null, new HotkeyEventArgs { Hotkey = hotkey }); } else { base.WndProc(ref m); } }