全局鼠标挂钩+模拟鼠标输入 [英] Global Mouse Hook + Simulate Mouse Inputs
问题描述
我正在寻找一个可以在XP/Vista/7中运行的全局鼠标挂钩,这将允许我访问鼠标输入的X,Y值,并在它们敲入Windows之前对其进行修改...
我还希望能够在实际的鼠标输入之间模拟鼠标输入...
例如,假设我们的输入如下所示:
1:1,0 2:2,0 3:3,0 4:?,?
我希望能够拦截输入数字4并通过'if'语句运行它:如果输入的值与某些参数匹配,我想通过对其进行添加或减去来修改该值... >
USB鼠标的默认轮询速率为125Hz,最大轮询速率为1000hz ...
如果可能的话(尤其是将轮询速率设置为小于1000hz时),我想在实际的鼠标更新(关键)之间注入"输入,例如:
(以毫秒为单位)
0008-1,0 0016-1,0 0032-2,0
所以鼠标正在以125Hz的频率更新...我能检测输入的频率,然后每隔一个输入发送一个输入吗???因此,例如,我可以将鼠标频率从125hz翻倍"到250hz,并根据我设置的任何规则模拟自己的中间"更新...
这些似乎合理吗?现在,我正在使用C#,并且正在使用本教程中的"Gma.UserActivityMonitor"进行操作:解决方案
希望获取原始链接时的此链接鼠标输入会有所帮助,它包括一个为C#和C ++版本编写的库.它旨在允许在Windows中使用多个鼠标,但希望您可以模仿它要用于完成的任务.
I'm looking to create a global mouse hook that works in XP/Vista/7 which would allow me to access the X,Y values that the mouse is inputting, and modify those values before they hit Windows...
I also want to be able to simulate mouse inputs in between actual mouse inputs...
For example, lets say our inputs looked like this:
1: 1,0 2: 2,0 3: 3,0 4: ?,?
I want to be able to intercept input number 4 and run it through an 'if' statement: If the value of the input matches certain parameters, I want to modify the value by adding or subtracting from it...
A USB Mouse has a default polling rate of 125Hz and a maximum of 1000hz...
If possible (especially when the polling rate is set less than 1000hz) I would like to 'inject' inputs 'between' actual mouse updates (critical) so for example:
(in milliseconds)
0008 - 1,0 0016 - 1,0 0032 - 2,0
So the mouse is updating at 125Hz... Could I detect the frequency of inputs, and send an input every other input??? So for example I could 'double' the mouse frequency from 125hz to 250hz, and simulate my own 'in between' updates based on whatever rules I set...
Does any of these seem reasonable? Right now I am working in C# and I was working with the "Gma.UserActivityMonitor" from this tutorial here: http://www.codeproject.com/KB/cs/globalhook.aspx but for some reason I get a performance hit which makes utilizing this code with fullscreen games have an unusable lag on the mouse inputs due to the hook...
Perhaps I need to write something in C++? Any help would be greatly appreciated. Thanks!
Hopefully this link on grabbing raw mouse input will be helpful, it includes a library written for C# as well as a C++ version. It is meant to enable the use of multiple mice in Windows but hopefully you can emulate what it's using for what you want to accomplish.
这篇关于全局鼠标挂钩+模拟鼠标输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!