private void RegisterHotKeyUp(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, TextBox textBox, KeyEventArgs e) { try { var pressedKeys = Keys.GetPressdKeys(); pressedKeys = Keys.ClearRepeatedKeys(pressedKeys); pressedKeys = Keys.ClearMousKeys(pressedKeys); string str = _EmptyHKString; if (pressedKeys.Length == 0) { Keyboard.ClearFocus(); if (hotKeyCombination.IsInitialized) { str = hotKeyCombination.CombinationKeysName(); if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } else { int t = 0; t++; } var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey); globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k); _HotKeyManager.AddGlobalHotKey(globalHotKey); textBox.Text = str; } else { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } } } } catch (Exception ex) { Logger.WriteLog(ex); } }
private void RegisterHotKeyUp(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, KeyEventArgs e) { if (_disposed) { return; } try { var pressedKeys = Keys.GetPressdKeys(); pressedKeys = Keys.ClearRepeatedKeys(pressedKeys); pressedKeys = Keys.ClearMousKeys(pressedKeys); if (pressedKeys.Length == 0) { Keyboard.ClearFocus(); if (hotKeyCombination.IsInitialized) { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey); globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k); _HotKeyManager.AddGlobalHotKey(globalHotKey); } else { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } } } } catch (Exception ex) { Logger.WriteLog(ex); } }
private void ReRegisterGlobalHotekey(HotKeyManager hotKeyManager, ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination) { if (_disposed) { return; } if (globalHotKey != null) { hotKeyManager.RemoveGlobalHotKey(globalHotKey); globalHotKey = null; } if (hotKeyCombination.IsInitialized) { var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey); globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k); hotKeyManager.AddGlobalHotKey(globalHotKey); } }
private void RegisterHotkey(HotKeyCombination combination, ref GlobalHotKey globalHotKey) { try { if (combination.IsInitialized) { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } var k = Keys.ConvertFromWpfKey(combination.NormalKey); globalHotKey = new GlobalHotKey(combination.Name, combination.ModifierKey, k); _HotKeyManager.AddGlobalHotKey(globalHotKey); } } catch (Exception e) { Logger.WriteLog(e); } }