0

有没有办法找出鼠标事件来自哪里?我的意思是,如果我在 Windows 上编写 C/C++ 程序并在其上获得鼠标单击事件,我如何才能确定该事件是来自鼠标驱动程序、触摸板还是由应用程序发送(鼠标事件通过发送适当的消息(如 WM_LBUTTONDOWN)进行模拟。

谢谢你的帮助 :)

4

2 回答 2

2

This is not possible for an application in user mode - mouse events generally don't provide documented info on event source. There is the way to obtain some message extra info by Win32 API function GetMessageExtraInfo but there is no safe way to interpret this data. It is very device specific, undocumented and never guaranteed to ever present.

To solve this task you need to develop your own Mouse Filter driver basing on Windows DDK sample.

Its callback has input parameter MOUSE_INPUT_DATA - structure containing mouse event info. There is the field UnitId:

UnitId Specifies the unit number of the mouse device. A mouse device name has the format \Device\PointerPortN, where the suffix N is the unit number of the device. For example, a device, whose name is \Device\PointerPort0, has a unit number of zero, and a device, whose name is \Device\PointerPort1, has a unit number of one.

于 2012-09-27T15:25:56.617 回答
0

GetAsyncKeyState 函数可用于检查按钮是否被按下,不幸的是 SendInput 无法欺骗该函数。所以你可以模拟鼠标点击,但程序可以检查按钮是否真的被按下。

因此,创建自己的鼠标驱动程序会更好。我需要一种安全的方法来模拟我的机器人的鼠标/键盘行为,我在我的博客http://poker-botting.blogspot.fr/2012/11/how-to-simulate-mouse-and-上写了一篇详细的文章键盘.html

于 2012-11-11T00:08:40.410 回答