Exemple #1
0
        public bool registerHotkey(ModifierKeys_e controlKeys, Keys key, funcDelegate func)
        {
            bool registerOk = false;

            KeyboardHook hook = new KeyboardHook();

            // register the event that is fired after the key press.
            hook.KeyPressed += new EventHandler <KeyPressedEventArgs>(func);

            try
            {
                hook.RegisterHotKey(controlKeys, key);
                registerOk = true;
            }
            catch (Exception ex)
            {
                registerOk = false;
                MessageBox.Show(ex.Message);
            }

            return(registerOk);
        }
        public bool registerHotkey(ModifierKeys_e controlKeys, Keys key, funcDelegate func)
        {
            bool registerOk = false;

            KeyboardHook hook = new KeyboardHook();

            // register the event that is fired after the key press.
            hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(func);

            try
            {
                hook.RegisterHotKey(controlKeys, key);
                registerOk = true;
            }
            catch (Exception ex)
            {
                registerOk = false;
                MessageBox.Show(ex.Message);
            }

            return registerOk;
        }