检测模拟的键盘/鼠标输入 [英] Detecting simulated keyboard/mouse input

查看:625
本文介绍了检测模拟的键盘/鼠标输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在Windows上检测模拟的键盘/鼠标输入。例如,用户在键盘上键入内容,而不是sendKeys / PostMessage /屏幕键盘。我可以区分两者吗?

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 a way that I can distinguish between the two?

编辑:也许一个例子会有所帮助。我正在制作游戏,想区分真实输入与WinAPI合成键盘/鼠标消息。

Perhaps an example would help. I am making a game and want to distinguish between real input vs WinAPI synthesizing keyboard/mouse messages.

推荐答案

我可能是错的,但是屏幕键盘(和其他模拟用户输入的应用程序)最有可能使用SendInput API:

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


SendInput在底层运行输入堆栈。它只是键盘和鼠标驱动程序用来告诉窗口管理器用户已生成输入的相同输入机制的后门。
来源: 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.

这篇关于检测模拟的键盘/鼠标输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆