private void PipeAnnotationForm_Shown(object sender, EventArgs e) { if (ActionType != ActionType.Idle && SelectedElementIds.Count() > 0) { SelectedElementIds.Clear(); DialogResult = DialogResult.Retry; return; } //加载钩子 KeyBoarHook = new KeyBoardHook(); KeyBoarHook.SetHook(); KeyBoarHook.OnKeyDownEvent += KeyBoarHook_OnKeyDownEvent; }
/// <summary> /// Try Catch 流程模板 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="func"></param> /// <param name="onError"></param> /// <returns></returns> public static bool DelegateKeyBoardHook(Action action) { KeyBoardHook hook = new KeyBoardHook(); hook.SetHook(); try { action(); Unhook(hook); return(true); } catch (Exception ex) { Unhook(hook); return(false); } }
public void ActivateKeyboardHook() { hookID = KeyBoardHook.SetHook(this.HandleKeyboardEvent); }
void Hook() { KeyBoarHook = new KeyBoardHook(); KeyBoarHook.SetHook(); KeyBoarHook.OnKeyDownEvent += KeyBoarHook_OnKeyDownEvent; }