Exemplo n.º 1
0
        internal void RegisterHotKey(string hotKeyString)
        {
            KeyboardHookModifierKeys modifiers = KeyboardHookModifierKeys.None;
            string modifiersString             = Properties.Settings.Default.HotKey;

            if (!string.IsNullOrEmpty(modifiersString))
            {
                if (modifiersString.ToLower().Contains("alt"))
                {
                    modifiers |= KeyboardHookModifierKeys.Alt;
                }
                if (modifiersString.ToLower().Contains("ctrl"))
                {
                    modifiers |= KeyboardHookModifierKeys.Control;
                }
                if (modifiersString.ToLower().Contains("shift"))
                {
                    modifiers |= KeyboardHookModifierKeys.Shift;
                }
                if (modifiersString.ToLower().Contains("win"))
                {
                    modifiers |= KeyboardHookModifierKeys.Win;
                }
            }

            RegisterHotKey(modifiers,
                           HotkeyControl.HotkeyFromString(
                               Properties.Settings.Default.HotKey));
        }
Exemplo n.º 2
0
        internal void RegisterHotKey()
        {
            KeyboardHookModifierKeys modifiers = KeyboardHookModifierKeys.None;
            string modifiersString             = Properties.Settings.Default.HotKey;

            if (!string.IsNullOrEmpty(modifiersString))
            {
                if (modifiersString.ToUpperInvariant().Contains("ALT", StringComparison.InvariantCulture))
                {
                    modifiers |= KeyboardHookModifierKeys.Alt;
                }

                if (modifiersString.ToUpperInvariant().Contains("CTRL", StringComparison.InvariantCulture) ||
                    modifiersString.ToUpperInvariant().Contains("STRG", StringComparison.InvariantCulture))
                {
                    modifiers |= KeyboardHookModifierKeys.Control;
                }

                if (modifiersString.ToUpperInvariant().Contains("SHIFT", StringComparison.InvariantCulture))
                {
                    modifiers |= KeyboardHookModifierKeys.Shift;
                }

                if (modifiersString.ToUpperInvariant().Contains("WIN", StringComparison.InvariantCulture))
                {
                    modifiers |= KeyboardHookModifierKeys.Win;
                }
            }

            RegisterHotKey(
                modifiers,
                HotkeyControl.HotkeyFromString(
                    Properties.Settings.Default.HotKey));
        }
Exemplo n.º 3
0
            /// <summary>
            /// Overridden to get the notifications.
            /// </summary>
            /// <param name="m">m.</param>
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);

                // check if we got a hot key pressed.
                if (m.Msg == WmHotkey)
                {
                    // get the keys.
                    Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                    KeyboardHookModifierKeys modifier = (KeyboardHookModifierKeys)((int)m.LParam & 0xFFFF);

                    // invoke the event to notify the parent.
                    KeyPressed?.Invoke(this, new KeyPressedEventArgs(modifier, key));
                }
            }
Exemplo n.º 4
0
 internal KeyPressedEventArgs(KeyboardHookModifierKeys modifier, Keys key)
 {
     _modifier = modifier;
     _key      = key;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Registers a hot key in the system.
 /// </summary>
 /// <param name="modifier">The modifiers that are associated with the hot key.</param>
 /// <param name="key">The key itself that is associated with the hot key.</param>
 //internal void RegisterHotKey(KeyboardHookModifierKeys modifier, Keys key)
 internal void RegisterHotKey(KeyboardHookModifierKeys modifier, Keys key)
 {
     RegisterHotKey((uint)modifier, key);
 }