Detecting simulated keyboard/mouse input(检测模拟键盘/鼠标输入)
问题描述
有没有办法检测 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
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.
这篇关于检测模拟键盘/鼠标输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检测模拟键盘/鼠标输入
基础教程推荐
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- Windows Media Foundation 录制音频 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01