How to detect if keystroke was emulated by keybd_e

2020-07-27 05:47发布

问题:

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?

回答1:

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.