public static void Register(HotKeyModel model) { var config = ColorPickerKey.CreateSubKey("Config"); config.SetValue("Type", model.SelectType); config.SetValue("Key", model.SelectKey); }
/// <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); }
public bool RegisterGlobalHotKey(HotKeyModel hotKeyModelList) { if (RegisterGlobalHotKeyEvent != null) { return(RegisterGlobalHotKeyEvent(hotKeyModelList)); } return(false); }