public void RegisterHotkey(IntPtr hWnd, MK modifier, VK_Keys key, PerformHotkeyAction action, string actionParameter) { HotkeyStore hks = new HotkeyStore() { ActionParameter = actionParameter, HWnd = hWnd, Action = action, Controller = (VK_Keys)(int)key, Modifier = modifier, UniqueIdentifier = incrementalHotkeyRegister }; if (!hks.Register()) { int err = Marshal.GetLastWin32Error(); string secondary = "Error:" + err.ToString(); if (err == 1409) { secondary = "The hotkey has already been registered. Use a different combination than (" + modifier.ToString() + "+" + key.ToString(); } throw new InvalidProgramException("The call to register a hotkey with windows failed. " + secondary); } interestedKeyCombos.Add(hks); incrementalHotkeyRegister++; }
public void RegisterHotkey(IntPtr hWnd, string keyString, PerformHotkeyAction action, string actionParameter) { MK mod; VK_Keys key; ParseKeyStringToModAndKey(keyString, out mod, out key); RegisterHotkey(hWnd, mod, key, action, actionParameter); }