/// <summary> /// Unregister a registered HotKey /// </summary> /// <param name="hotKeys"></param> /// <returns></returns> public static bool UnRegisterHotKey(HotKeys hotKeys) { Instancied.WaitOne(); try { return((bool)_instance.Invoke(new Func <bool>(() => { int id; if (!_instance._registeredHotkeys.TryGetValue(hotKeys, out id)) { return false; } _instance._registeredHotkeys.Remove(hotKeys); return NativeMethods.UnregisterHotKey(_instance.Handle, id); }))); } finally { Instancied.Set(); } }
/// <summary> /// Registers a HotKey in the system. /// </summary> /// <param name="hotKeys">Represent the hotkey to register</param> public static bool RegisterHotKey(HotKeys hotKeys) { Instancied.WaitOne(); try { return((bool)_instance.Invoke(new Func <bool>(() => { if (_instance._registeredHotkeys.ContainsKey(hotKeys)) { return false; } var id = _instance._hotKeyId++; _instance._registeredHotkeys.Add(hotKeys, id); // register the hot key. return NativeMethods.RegisterHotKey(_instance.Handle, id, (uint)hotKeys.Modifier, (uint)hotKeys.Keys); }))); } finally { Instancied.Set(); } }
public KeyPressedEventArgs(HotKeys hotKeys) { HotKeys = hotKeys; }