跟踪鼠标输入事件

Tracking mouse input events

目前正在使用SendInput(MOUSEEVENTF_MOVE)模拟鼠标移动。 SendInput 在处理之前将新的鼠标事件添加到线程输入队列。

是否可以 track/check 如果特定事件已实际处理?

WndProc 中的跟踪 WM_MOUSEMOVE 不是选项,因为用户可能同时发出非模拟鼠标移动。

Is it possible to track/check if an specific event has actually been processed?

总的来说:没有

SendInput adds a new mouse event to the thread input queue before being processed.

嗯,不。 SendInput 将输入事件放入硬件输入队列,在那里它们被原始输入线程拾取,并分派到各自线程的输入队列。

Tracking WM_MOUSEMOVE in WndProc is no option since it is possible for the user to issue non-simulated mouse movements at the same time.

正确。但是,您可以安装 low-level mouse hook, where you can identify injected input1. Injected input has one of the LLMHF_INJECTED or LLMHF_LOWER_IL_INJECTED flags set in the MSLLHOOKSTRUCT 结构的 flags 成员。

一个允许您识别应用程序 window 过程的鼠标消息处理程序中注入输入的脆弱解决方案是通过 MOUSEINPUT structure. This value can be queried in the message handler by calling GetMessageExtraInfo.但是,它是不可靠的,因为系统也使用这些值。应用程序可以使用的值没有范围,保证不会与系统使用的值冲突。


1 低级鼠标挂钩在输入事件从硬件输入队列中出列后运行。事件尚未被应用程序处理,甚至尚未放入相应线程的输入队列中。