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); }
public static void UnregisterHotkey(ECHotkey _hotkey) { UnregisterHotKey(form.Handle, _hotkey.id); }