예제 #1
0
        public static void Register(HotKeyModel model)
        {
            var config = ColorPickerKey.CreateSubKey("Config");

            config.SetValue("Type", model.SelectType);
            config.SetValue("Key", model.SelectKey);
        }
예제 #2
0
        /// <summary>
        /// 注册热键
        /// </summary>
        /// <param name="hotKeyModel">热键待注册项</param>
        /// <param name="hWnd">窗口句柄</param>
        /// <returns>成功返回true,失败返回false</returns>
        public static bool RegisterHotKey(HotKeyModel hotKeyModel, IntPtr hWnd)
        {
            var fsModifierKey = new ModifierKeys();

            HotKeyManager.UnregisterHotKey(hWnd, HotKeyManager.COPY_ID);

            // 注册热键
            if (hotKeyModel.SelectType == EType.Alt)
            {
                fsModifierKey = ModifierKeys.Alt;
            }
            else if (hotKeyModel.SelectType == EType.Ctrl)
            {
                fsModifierKey = ModifierKeys.Control;
            }
            else if (hotKeyModel.SelectType == EType.Shift)
            {
                fsModifierKey = ModifierKeys.Shift;
            }

            var result = HotKeyManager.RegisterHotKey(hWnd, HotKeyManager.COPY_ID, fsModifierKey, (int)hotKeyModel.SelectKey);

            if (result)
            {
                RegistryManager.Register(hotKeyModel);
            }
            return(result);
        }
예제 #3
0
 public bool RegisterGlobalHotKey(HotKeyModel hotKeyModelList)
 {
     if (RegisterGlobalHotKeyEvent != null)
     {
         return(RegisterGlobalHotKeyEvent(hotKeyModelList));
     }
     return(false);
 }