public void UnicodeKeyStrokeTest() { sender.UnicodeKeyStroke("A"); Assert.AreEqual(keyboardEvents[0].Item1, LowLevelKeyboardHook.Event.WM_KEYDOWN); Assert.AreEqual(keyboardEvents[0].Item2.vkCode, 0xE7U); Assert.AreEqual(keyboardEvents[0].Item2.scanCode, 'A'); Assert.IsFalse(keyboardEvents[0].Item2.flags.HasFlag(LowLevelKeyboardHook.FLAGS.LLKHF_EXTENDED)); Assert.AreEqual(keyboardEvents[1].Item1, LowLevelKeyboardHook.Event.WM_KEYUP); Assert.AreEqual(keyboardEvents[1].Item2.vkCode, 0xE7U); Assert.AreEqual(keyboardEvents[1].Item2.scanCode, 'A'); Assert.IsFalse(keyboardEvents[1].Item2.flags.HasFlag(LowLevelKeyboardHook.FLAGS.LLKHF_EXTENDED)); }
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); }