将鼠标移动事件从10毫秒更改为1毫秒 [英] Change the Mouse Move Event from 10msec to 1msec

查看:145
本文介绍了将鼠标移动事件从10毫秒更改为1毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Basic Express 2010和Windows XP SP3.

我希望每毫秒都可以发生鼠标移动事件".

现在,我只能在一秒钟内确定100个样本的鼠标事件.

能不能给我一个暗示,我可以在一秒钟内确定1000个样本的鼠标事件?


我需要如此高的分辨率才能确定一项心理任务的反应时间.

另外,所显示图片的大小也随时间而变化–如果我每秒仅处理100个样本,有时会看到这种情况.

I use Visual Basic Express 2010 and Windows XP SP3.

I would want that Mouse Move Events every millisecond can occur.

At now I can only determine Mouse Events with 100 samples in a second.

Can please give me somebody a hint that I can determine Mouse Events with 1000 samples in a second?


I need such high resolution to determine reaction times in a psychological task.

Also time-depended the size of a presented picture changes – this could be seen sometimes, if I work only with 100 samples in a second.

推荐答案

我不知道以任何方式做到这一点,如果您考虑到这一点,这是有道理的.如果您能够设置所需的频率并连续移动鼠标,则将没有时间使用任何操作系统功能等.

通过在控制面板"中试验鼠标的设置,您也许可以得到一些细微的改进,但我不确定.

当然,现在我已经说了这一点,有人会来证明我是错误的. :)
I am not aware of any way to do this and if you think about it that makes sense. If you were able to set the frequency as high as you would like and continuously move the mouse there would be no time for any of the operating system functions etc.

You may be able to get some slight improvement by experimenting with the settings for your mouse in Control Panel but I am not sure.

Of course now that I have said this, someone will come along and prove me wrong. :)


我必须同意Henry的观点,但我想补充一点,MouseMove Event由继承自Control的所有类(包括Form)引发.这个Control类引发Event,除非您找到在Control和MouseMove的RaiseEvent之间找到一种方法,否则我认为没有任何方法可以做到这一点.也许您可以编写自己的控件类,并使它更频繁地引发MouseMove事件.这意味着您将不得不重写从Control继承的每个类,并使它从您自己的Control类继承.完成后,您已经重写了框架的一半,然后亨利的性能问题就会出现; p

可能的替代方法是使用计时器,将其时间间隔设置为1,然后检查鼠标是否在您想要的控件上,并提高其MouseMoveEvent.当然,该事件将每100毫秒引发两次(从计时器发出一次,从您的实际事件发出一次).再一次,亨利的性能问题仍然适用.

总而言之,我认为这不是一个好主意.
您为什么还要每秒检查一次1000次?我们的眼睛甚至看不到这种运动.
I must agree with Henry, but would like to add that the MouseMove Event is raised by all classes that Inherit from Control, including a Form. This Control Class raises the Event, and unless you could find a way to come between the Control and the RaiseEvent of the MouseMove I do not think there is any way to do this. Perhaps you could write your own Control Class and have it raise the MouseMove Event more often. That would mean you would have to rewrite every Class that Inherits from Control and have it Inherit from your own Control Class. When you are done you have rewritten half of the framework and then Henry''s performance issues will kick in ;p

Perhaps an alternative would be to use a timer, set its interval to 1 and check if the mouse is on the control you want it to be and raise its MouseMoveEvent. Of course the Event will be raised twice every 100 milliseconds (once from the timer and once from your actual event). And once again Henry''s performance issues will still apply.

All in all I do not think it is a good idea.
Why would you want to check it 1000 times every second anyway? Our eyes cannot even see such movement.


这是那些奇怪的要求之一.很多时候,我们在完全了解问题之前会选择解决方案.我确定您想知道鼠标事件是有原因的.但是,在您盘旋而摔倒头部之前,我要提醒您,鼠标是通用"输入设备,因此不要指望也不应该尝试将其用于高分辨率解决方案.

以Windows计时器为例,虽然它可以很好地用作通用计时器,但毫秒级的精度并不重要,但它不是高分辨率计时器的正确工具.

如果您确实需要具有事件的高分辨率鼠标,并且对您有非常实际的要求,那么真正的解决方案是不使用Visual Basic(就此而言,.NET甚至根本不扩展Windows事件).由于这些并非旨在提供如此高的卡尺分辨率,因此是通用解决方案.

虽然我不知道您的问题,但我正在做出一个疯狂的猜测,但是您可以使用现有的鼠标事件,看看是否可以通过其他方法解决您的问题.但同样,您的情况可能不是典型情况之一.
This is one of those strange requirements. Many times, we pick our solutions before knowing fully the problem. I am sure there is a reason why you want to know the mouse events. But before you go in spiral and crash your head, I want you to keep in mind, that the mouse is a *general* purpose input device, as such don''t expect nor should you attempt to use it for high resolution solutions.

Take for instance the windows timer, while it server well for general purpose timer, where the precision of some degree milliseconds does not matter, but it is not the right tool for high resolution timer.

If you truly need such high resolution mouse with events and there is very real requirement on your side, then the real solution is not to use Visual Basic (for that matter .NET even by extension Windows events at all). As those are not meant to serve such high caliper resolution, rather general purpose solutions.

While I don''t know your problem and I am making a wild guess, you may be ok to use the existing mouse events and see if your problem can be addressed through other means. But again your situation may not be one of those typical ones.


这篇关于将鼠标移动事件从10毫秒更改为1毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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