private void update_shortcut_key() { HotKeyboardHook.ModifierKeys m_keys = 0; if (FOptions.shortcutShift) { m_keys |= HotKeyboardHook.ModifierKeys.Shift; } if (FOptions.shortcutAlt) { m_keys |= HotKeyboardHook.ModifierKeys.Alt; } if (FOptions.shortcutCntrl) { m_keys |= HotKeyboardHook.ModifierKeys.Control; } if (FOptions.shortcutWin) { m_keys |= HotKeyboardHook.ModifierKeys.Win; } if (kb_shortcut != null && (shortcut_last_mod != m_keys || shortcut_last_key != FOptions.shortcutKey)) { kb_shortcut.Dispose(); kb_shortcut = null; } if (kb_shortcut == null && !string.IsNullOrEmpty(FOptions.shortcutKey) && m_keys != 0) { kb_shortcut = new HotKeyboardHook(); kb_shortcut.KeyPressed += handle_keyboard_shortcut; char key = FOptions.shortcutKey[0]; try { kb_shortcut.RegisterHotKey(m_keys, (Keys)key); }catch (Exception e) { MessageBox.Show("KPFloatingPanel: Unable to register QuickPass hotkey due to: " + e.Message); } shortcut_last_key = FOptions.shortcutKey; shortcut_last_mod = m_keys; } }
private void update_shortcut_key_quick() { HotKeyboardHook.ModifierKeys m_keys = 0; if (FOptions.shortcutShiftQuick) m_keys |= HotKeyboardHook.ModifierKeys.Shift; if (FOptions.shortcutAltQuick) m_keys |= HotKeyboardHook.ModifierKeys.Alt; if (FOptions.shortcutCntrlQuick) m_keys |= HotKeyboardHook.ModifierKeys.Control; if (FOptions.shortcutWinQuick) m_keys |= HotKeyboardHook.ModifierKeys.Win; if (kb_shortcut_quick != null && (shortcut_last_mod_quick != m_keys || shortcut_last_key_quick != FOptions.shortcutKeyQuick)) { kb_shortcut_quick.Dispose(); kb_shortcut_quick = null; } if (kb_shortcut_quick == null && !string.IsNullOrEmpty(FOptions.shortcutKeyQuick) && m_keys != 0) { kb_shortcut_quick = new HotKeyboardHook(); kb_shortcut_quick.KeyPressed += handle_keyboard_shortcut_quick; char key = FOptions.shortcutKeyQuick[0]; try{ kb_shortcut_quick.RegisterHotKey(m_keys, (Keys)key); }catch (Exception e) { MessageBox.Show("KPFloatingPanel: Unable to register QuickPass hotkey due to: " + e.Message); } shortcut_last_key_quick = FOptions.shortcutKeyQuick; shortcut_last_mod_quick = m_keys; } }
internal KeyPressedEventArgs(HotKeyboardHook.ModifierKeys modifier, WF.Keys key) { _modifier = modifier; _key = key; }