Exemplo n.º 1
0
        public static bool RegisterHotKey(this HotKeyData keyData, Form parent)
        {
            if (!keyData.UseHotKey)
            {
                return(true);
            }

            // update HotKey
            User32HotKey.KeyModifiers modifiers = User32HotKey.KeyModifiers.None;

            if (keyData.KeyData.HasFlag(Keys.Control))
            {
                modifiers |= User32HotKey.KeyModifiers.Control;
            }
            if (keyData.KeyData.HasFlag(Keys.Shift))
            {
                modifiers |= User32HotKey.KeyModifiers.Shift;
            }
            if (keyData.KeyData.HasFlag(Keys.Alt))
            {
                modifiers |= User32HotKey.KeyModifiers.Alt;
            }
            if (keyData.KeyData.HasFlag(Keys.LWin) || keyData.KeyData.HasFlag(Keys.RWin))
            {
                modifiers |= User32HotKey.KeyModifiers.Windows;
            }

            Keys key = (Keys)((int)keyData.KeyData & 0x0000FFFF); //filter out modifiers

            LogC.WriteLine("RegisterHotKey: " + keyData);
            return(User32HotKey.RegisterHotKey(parent.Handle, keyData.AppId, modifiers, key));
        }        //end RegisterHotKey
Exemplo n.º 2
0
        }        //end RegisterHotKey

        public static void UnregisterHotKey(this HotKeyData keyData, Form parent)
        {
            LogC.WriteLine("UnregisterHotKey: " + keyData);
            User32HotKey.UnregisterHotKey(parent.Handle, keyData.AppId);
        } //end UnregisterHotKey