473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Monitor mouse events in application

I need to monitor the status of the mouse on an application-wide basis (i.e., not just for the control that owns the mouse). One I idea I had was to create a shared class that inherits from timer and tests Windows.Forms.Control.MouseButtons and Windows.Forms.Cursor.Current.Position in the tick event. Obviously this technique is not perfect because I am relying on the tick event. Also, I've discovered that Windows.Forms.Control.MouseButtons does not update immediately when the user clicks the title area of a form (i.e., when the form's Text, Icon, and ControlBox are displayed). Is there a better technique

Thank you
Lance
Nov 20 '05 #1
2 1826
* "=?Utf-8?B?TGFuY2U=?=" <zi***@hotmail.com> scripsit:
I need to monitor the status of the mouse on an application-wide basis
(i.e., not just for the control that owns the mouse). One I idea I had
was to create a shared class that inherits from timer and tests
Windows.Forms.Control.MouseButtons and
Windows.Forms.Cursor.Current.Position in the tick event. Obviously this
technique is not perfect because I am relying on the tick event. Also,
I've discovered that Windows.Forms.Control.MouseButtons does not update
immediately when the user clicks the title area of a form (i.e., when
the form's Text, Icon, and ControlBox are displayed). Is there a better
technique?


A mouse hook ('WM_MOUSE' or similar) would be a more reliable way:

Article on keyboard hooks (can be adapted for mouse hooks):

<URL:http://www.developer.com/net/net/article.php/11087_2193301_1/>

Documentation on hooks:

<URL:http://msdn.microsoft.com/library/en-us/dnwui/html/msdn_hooks32.asp>
<URL:http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/hooks.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Great. Thanks.
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bill Henning | last post by:
Does anyone know a good method of preventing keyboard and mouse events from interrupting processing? My situation is: 1) I need to track and handle all key and mouse events 2) I need to perform...
3
by: Logan Mckinley | last post by:
I need to be able to detect mouse movement even when it is not over my application. I can get the mouse cords using MousePosition but I am not sure if there is an event that hits my program when...
2
by: KarenP | last post by:
In my Windows Forms application, while executing a process that takes some time, I am changing the cursor to the hourglass by setting Cursor.Current = Cursors.WaitCursor. This is working just...
3
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as...
2
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
7
by: Dave | last post by:
Is there a way to query the monitor status, to know if it is on or off in C#? I found that WM_SYSCOMMAND is sent to WndProc when the monitor goes on and off but im not sure to find out if that...
6
by: ewolfman | last post by:
Hi, Is there any way in which I can monitor / hook the Registry, and upon a call to a specific key from a specific application - swap the returned value? I was thinking of using this method...
18
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested...
3
by: kalyanilovesme | last post by:
Hi, I am running my application in two minitors.In one monitor.............if it is idle for some time the screensaver wil come(I wrote the code for this using system dll functions) . Now my...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.