I'm developing an application which needs to count user keystrokes. It works fine however user can trick the app with SendInput() WINAPI function. Is it any way to differentiate between keystrokes made by real user and those sent via SendInput?
+2
A:
Set a hook with SetWindowsHookEx
with the type WH_KEYBOARD_LL
. Your callback can inspect the KBDLLHOOKSTRUCT::flags
field. If it has the LLKHF_INJECTED
flag set, then it's from SentInput
or keybd_event
. Otherwise, it's from the local keyboard driver.
MSN
2009-09-03 21:45:45