コード例 #1
0
        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();
        }
コード例 #2
0
 private void RegisterGlobalHotkey(GlobalKeyboardHook HotKey, KeyEventHandler target)
 {
     HotKey.KeyDown += target;
 }