问题
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.
来源:https://stackoverflow.com/questions/45008637/how-to-detect-if-keystroke-was-emulated-by-keybd-event-or-sendinput