public void UnhookThrowsInvalidOperationExceptionTestTest() { var hook = new LowLevelKeyboardHook((evnt, data) => { return(LowLevelKeyboardHook.Result.Transfer); }); hook.SetHook(); hook.Unhook(); try { hook.Unhook(); } catch (InvalidOperationException) { return; } Assert.Fail(); }
public void ActivatedTest() { var hook = new LowLevelKeyboardHook((evnt, data) => { return(LowLevelKeyboardHook.Result.Transfer); }); Assert.IsFalse(hook.IsActivated); hook.SetHook(); Assert.IsTrue(hook.IsActivated); hook.Unhook(); Assert.IsFalse(hook.IsActivated); }
public void LowLevelKeyboardHookTest() { var sender = new SingleInputSender(); var list = new List <LowLevelKeyboardHook.Event>(); var hook = new LowLevelKeyboardHook((evnt, data) => { list.Add(evnt); return(LowLevelKeyboardHook.Result.Cancel); }); Assert.AreEqual(list.Count, 0); hook.SetHook(); sender.UnicodeKeyStroke("A"); hook.Unhook(); Assert.AreEqual(list.Count, 2); }
private void playHotkey_HotkeyPressed(object sender, EventArgs e) { if (state == MacroState.STOPPED) { lastTickCount = Environment.TickCount; state = MacroState.PLAYING; if (llhook) { llindex = 0; if (bi) { iblock = new InputBlocker(); } playTimer.Interval = 1; playTimer.Enabled = true; } else { index = 0; play = new JournalPlaybackHook(); play.GetNextJournalMessage += new JournalPlaybackHook.JournalQuery(play_GetNextJournalMessage); play.StartHook(); } } else if (state == MacroState.PLAYING) { // do nothing } else { if (llhook) { kbd.Unhook(); mouse.Unhook(); } else { rec.Unhook(); } state = MacroState.STOPPED; RemoveEvent(playHotkey.KeyCode); } UpdateIcons(); }
public static void ClassCleanup() { mouseHook.Unhook(); keyboardHook.Unhook(); }