Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 20-Mar-11 5:26am
v3

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. :)
 
Share this answer
 
Comments
Albin Abel 20-Mar-11 0:16am    
Yes, that right. I thought the same before seeing your answer. If OP do that OP will be end up optimizing lot of things in the OS. So my 100+
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.
 
Share this answer
 
v2
Comments
Henry Minute 19-Mar-11 20:08pm    
5Beautifully put.
Albin Abel 20-Mar-11 0:14am    
Agree. The present speed of the mouse movement is optimized for the OS. When we change that there will be unpredictable problems and it is not simply changing the speed, but result in lot of customized optimization. That may not be cost effective. As you said alternatively OP may emulate the condition through a business logic. Using timer or whatever. My 100+
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.
 
Share this answer
 
Comments
Albin Abel 20-Mar-11 0:18am    
Yes, you said it right. Instead of increase the speed of the mouse, OP may emulate a device independent solution in his business logic. My 100+
On top of everything else that's been said, you can't even process mouse events that fast to begin with. Getting 1 ms resolution will only fill up the apps message queue to the point where other messages, such as window repaints, won't get processed in time to show the results of your mouse moves. There will be a noticable lag in your UI as the code races to process all the messages that have piled up.

Also, changing the sampling rate cannot be done on an application-by-application basis. That change will affect all other applications running on the system, potentially making it unusable.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Mar-11 22:02pm    
Correct, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900