/// <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>
        public void RegisterHotKey(HotKeyModifierKeys modifier, Keys key)
        {
            // increment the counter.
            _currentId = _currentId + 1;

            // register the hot key.
            if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
            {
                throw new InvalidOperationException("Couldn’t register the hot key.");
            }
        }
Exemple #2
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == HotkeyManager.WM_HOTKEY)
            {
                Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                HotKeyModifierKeys modifier = (HotKeyModifierKeys)((int)m.LParam & 0xFFFF);
                HotkeyPressed(modifier, key);
            }
        }
Exemple #3
0
        public void HotkeyPressed(HotKeyModifierKeys modifierKeys, Keys key)
        {
            int x = -1;

            switch (key)
            {
            case Keys.D1: x = 0; break;

            case Keys.D2: x = 1; break;

            case Keys.D3: x = 2; break;

            case Keys.D4: x = 3; break;

            case Keys.D0: _showAllScreenForm = true;  break;
            }
            if (x != -1)
            {
                butScreen_Click(_buttons[x], new EventArgs());
            }
        }
 internal KeyPressedEventArgs(HotKeyModifierKeys modifier, Keys key)
 {
     _modifier = modifier;
     _key      = key;
 }