/// <summary> /// Registers a hotkey to Windows hotkey table. /// </summary> /// <param name="hk">The hotkey to register.</param> /// <returns>Whether the registration is successful.</returns> private static bool RegisterHotkey(Hotkey hk) { if (_windowHandle == IntPtr.Zero) { throw new InvalidOperationException("The window handle is not initialized."); } return(HotkeyInterop.RegisterHotKey(_windowHandle, hk.Id, hk.KeyCombo.ModifierKeys, KeyInterop.VirtualKeyFromKey(hk.KeyCombo.Key))); }
/// <summary> /// Removes a hotkey from Windows hotkey table. /// </summary> /// <param name="hk">The hotkey to unregister.</param> /// <returns>Whether the unregistration is successful.</returns> private static bool UnregisterHotkey(Hotkey hk) { return(HotkeyInterop.UnregisterHotKey(_windowHandle, hk.Id)); }