private void CreateGlobalHotkey() { globalHotKey = new GlobalKeyboardHook(); foreach (string token in Properties.Settings.Default.Hotkey.Split('+')) { switch (token) { case "CTRL": globalHotKey.Ctrl = true; break; case "ALT": globalHotKey.Alt = true; break; case "WIN": globalHotKey.Windows = true; break; case "SHIFT": globalHotKey.Shift = true; break; default: globalHotKey.HookedKeys.Add((Keys)Enum.Parse(typeof(Keys), token)); break; } } RegisterGlobalHotkey(globalHotKey, HotKeyEvent); hotkey_label.Text = Properties.Settings.Default.Hotkey.ToString(); }
private void RegisterGlobalHotkey(GlobalKeyboardHook HotKey, KeyEventHandler target) { HotKey.KeyDown += target; }