RegisterHotKey() private method

private RegisterHotKey ( IntPtr hWnd, int id, uint fsModifiers, uint vk ) : bool
hWnd System.IntPtr
id int
fsModifiers uint
vk uint
return bool
Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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;
            }
        }