예제 #1
0
        public static ECHotkey RegisterHotkey(Keys _keyAndModifiers, ECHotKeyHelperDelegate _callback)
        {
            if (_keyAndModifiers == 0)
            {
                return(null);
            }

            int key       = (int)_keyAndModifiers & (int)Keys.KeyCode;
            int modifiers = (int)_keyAndModifiers & (int)Keys.Modifiers;

            ECHotkey hotkey = new ECHotkey(nextKeyId, (Keys)key, (Keys)modifiers, _callback);

            hotkeys.Add(_keyAndModifiers, hotkey);

            if (!RegisterHotKey(form.Handle, nextKeyId, WinFormKeyToWinProcKey((Keys)modifiers), key))
            {
                throw new InvalidOperationException("Couldn’t register the hot key.");
            }

            nextKeyId++;
            return(hotkey);
        }
예제 #2
0
 public static void UnregisterHotkey(ECHotkey _hotkey)
 {
     UnregisterHotKey(form.Handle, _hotkey.id);
 }