Logging all mouse clicks in an application
-
I have an interesting requirement and was wondering if anyone might be able to point me in a direction that could get me started. I've developed an application that is used on many workstations in the company and all access the same database. From time to time I see little issues in the DB that I can't figure out how a user might have managed to make the particular change. It might be a bug in my code but it's such a difficult issue to debug as I usually can't even replicate the problem. So I was wondering if it would be possible to write some or other function that is called every time the user clicks on any control on the form. This procedure then stores the name of the control, the date and time and perhaps even the coordinates of the click (or something like that) to a List which can then either be written to a local log file or to some table in the DB. This way I'd be able to see exactly the sequence of clicks that preceded a certain change in the DB. The problem is, the application is huge and I don't want to go add a line of code that calls this function at the start of every OnClick() event handler. Is there a way I could have my function called for every click that happens on any control in any form in the application before the relevant OnClick() event handler is called? Any ideas on alternative approaches that might help me track the users' mouse clicks would also be very welcome.
-
I have an interesting requirement and was wondering if anyone might be able to point me in a direction that could get me started. I've developed an application that is used on many workstations in the company and all access the same database. From time to time I see little issues in the DB that I can't figure out how a user might have managed to make the particular change. It might be a bug in my code but it's such a difficult issue to debug as I usually can't even replicate the problem. So I was wondering if it would be possible to write some or other function that is called every time the user clicks on any control on the form. This procedure then stores the name of the control, the date and time and perhaps even the coordinates of the click (or something like that) to a List which can then either be written to a local log file or to some table in the DB. This way I'd be able to see exactly the sequence of clicks that preceded a certain change in the DB. The problem is, the application is huge and I don't want to go add a line of code that calls this function at the start of every OnClick() event handler. Is there a way I could have my function called for every click that happens on any control in any form in the application before the relevant OnClick() event handler is called? Any ideas on alternative approaches that might help me track the users' mouse clicks would also be very welcome.
Dewald wrote:
Any ideas on alternative approaches that might help me track the users' mouse clicks would also be very welcome.
To start off; not every user uses the mouse. I'm using a keyboard simply because it's faster to hit a shortcut then it is to find the cursor, point to mouse to a specific region and click twice. And again, because the first mouse-click wasn't registered. What you'd like to trace, are the methods that are being executed. It sounds like PostSharp[^] could be helpful here. A lightweight solution would be to iterate through all the components of a form, and register an extra handler for the most interesting events, and log those.
Bastard Programmer from Hell :suss:
-
Dewald wrote:
Any ideas on alternative approaches that might help me track the users' mouse clicks would also be very welcome.
To start off; not every user uses the mouse. I'm using a keyboard simply because it's faster to hit a shortcut then it is to find the cursor, point to mouse to a specific region and click twice. And again, because the first mouse-click wasn't registered. What you'd like to trace, are the methods that are being executed. It sounds like PostSharp[^] could be helpful here. A lightweight solution would be to iterate through all the components of a form, and register an extra handler for the most interesting events, and log those.
Bastard Programmer from Hell :suss:
-
Dewald wrote:
Any ideas on alternative approaches that might help me track the users' mouse clicks would also be very welcome.
To start off; not every user uses the mouse. I'm using a keyboard simply because it's faster to hit a shortcut then it is to find the cursor, point to mouse to a specific region and click twice. And again, because the first mouse-click wasn't registered. What you'd like to trace, are the methods that are being executed. It sounds like PostSharp[^] could be helpful here. A lightweight solution would be to iterate through all the components of a form, and register an extra handler for the most interesting events, and log those.
Bastard Programmer from Hell :suss:
To start off; not every user uses the mouse.
This is true but buttons and menu items still fire 'click' events even if you select them with the keyboard (and, personally, I'd recommend you do this with any custom controls you write that have an action on click, too).
-
To start off; not every user uses the mouse.
This is true but buttons and menu items still fire 'click' events even if you select them with the keyboard (and, personally, I'd recommend you do this with any custom controls you write that have an action on click, too).
BobJanova wrote:
This is true but buttons and menu items still fire 'click' events even if you select them with the keyboard (and, personally, I'd recommend you do this with any custom controls you write that have an action on click, too).
Yup - but I still see a lot of buttons that only react on their
Control.MouseClick
event - just wanted to touch the subject to ensure that it's not overlooked :)Bastard Programmer from Hell :suss: