/// <summary> /// Indicates whether a <see cref="Hotkey"/> has been bound already either /// by this application or another application. /// </summary> /// <param name="hotkeyCombo"> /// The <see cref="Hotkey"/> to evaluate. /// </param> /// <returns> /// <c>true</c> if the <see cref="Hotkey"/> has not been previously bound /// and is available to be bound; otherwise, <c>false</c>. /// </returns> public bool IsHotkeyAlreadyBound(Hotkey hotkeyCombo) { bool successful = NativeMethods.RegisterHotKey( hotkeyWindow.Handle, hotkeyCombo.GetHashCode(), (uint)hotkeyCombo.Modifier, (uint)hotkeyCombo.Key); if (!successful) return true; NativeMethods.UnregisterHotKey( hotkeyWindow.Handle, hotkeyCombo.GetHashCode()); return false; }
private void UnregisterHotkey(Hotkey hotkeyCombo) { bool successful = NativeMethods.UnregisterHotKey( hotkeyWindow.Handle, hotkeyCombo.GetHashCode()); if (!successful) throw new HotkeyNotBoundException(Marshal.GetLastWin32Error()); }
private void RegisterHotkey(Hotkey hotkeyCombo) { bool successful = NativeMethods.RegisterHotKey( hotkeyWindow.Handle, hotkeyCombo.GetHashCode(), (uint)hotkeyCombo.Modifier, (uint)hotkeyCombo.Key); if (!successful) throw new Win32Exception(Marshal.GetLastWin32Error()); }