Detecting simulated keyboard/mouse input

前端 未结 3 1299
借酒劲吻你
借酒劲吻你 2020-12-10 23:30

Is there a way to detect simulated keyboard/mouse input on Windows. For example, a user types something on his keyboard vs sendKeys/PostMessage/On-screen keyboard. Is there

3条回答
  •  余生分开走
    2020-12-11 00:02

    I might be wrong, but the on-screen keyboard (and other applications that simulate user input) most probably uses the SendInput API:

    SendInput operates at the bottom level of the input stack. It is just a backdoor into the same input mechanism that the keyboard and mouse drivers use to tell the window manager that the user has generated input. Source: http://blogs.msdn.com/b/oldnewthing/archive/2010/12/21/10107494.aspx

    So there is probably no way to tell whether the input is coming from a "real" keyboard or not.

提交回复
热议问题