Reputation: 22275
Is it possible to detect in my custom Win32 control, while processing WM_CHAR, or WM_KEYDOWN message, whether the keystroke came from the actual keyboard, or was emulated by a call to SendInput or keybd_event type function?
Upvotes: 3
Views: 3109
Reputation: 596672
Starting in Windows 8, you can use the GetCurrentInputMessageSource()
function in your message handler. You can check if the reported originId
is IMO_HARDWARE
, IMO_INJECTED
, or IMO_SYSTEM
.
Upvotes: 3
Reputation: 101666
You could check if the LLKHF_INJECTED
flag is set in a low-level hook. I don't think you can tell just by looking at the LPARAM.
Upvotes: 3