/// <summary> /// 移除指定的热键. /// </summary> /// <param name="data"></param> /// <returns></returns> public bool Remove(HotKeyData data) { if (_HotMap.ContainsKey(data.ID)) { _HotMap.Remove(data.ID); return(HotKeyUtil.UnregisterHotKey(data.Hand, data.ID)); } return(false); }
/// <summary> /// 移除热键. /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Remove(int id) { if (_HotMap.ContainsKey(id)) { HotKeyData data = _HotMap[id]; _HotMap.Remove(id); return(HotKeyUtil.UnregisterHotKey(data.Hand, data.ID)); } return(false); }
/// <summary> /// 向系统注册一个热键. /// </summary> /// <param name="data">热键的描述信息.</param> /// <returns></returns> public bool RegisterHotKey(HotKeyData data) { if (data == null) { throw new ArgumentNullException("data"); } if (_HotMap.ContainsKey(data.ID)) { _HotMap.Add(data.ID, data); return(HotKeyUtil.RegisterHotKey(data.Hand, data.ID, data.Modifiers, data.Key)); } else { return(false); } }
/// <summary> /// 执行热键任务. /// <para>注意,执行任务时,默认为Action优先.调用线程的任务将不会执行.</para> /// </summary> /// <param name="id"></param> public bool RunHotKey(int id) { if (_HotMap.ContainsKey(id)) { HotKeyData data = _HotMap[id]; if (data.Action != null) { data.Action();//执行委托. } else { //开启线程 执行任务. System.Diagnostics.Process.Start(data.Command, data.Arguments); } return(true); } return(false); }