c00000fd
c00000fd

Reputation: 22275

How to detect if keystroke was emulated by keybd_event or SendInput?

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

Answers (2)

Remy Lebeau
Remy Lebeau

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

Anders
Anders

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

Related Questions