Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Logging all mouse clicks in an application

Logging all mouse clicks in an application

Scheduled Pinned Locked Moved C#
helpdatabasedebuggingquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dewald
    wrote on last edited by
    #1

    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.

    L 1 Reply Last reply
    0
    • D Dewald

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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:

      D B 2 Replies Last reply
      0
      • L Lost User

        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:

        D Offline
        D Offline
        Dewald
        wrote on last edited by
        #3

        OK, that sounds like a good approach. Thanks. I'll investigate that.

        L 1 Reply Last reply
        0
        • D Dewald

          OK, that sounds like a good approach. Thanks. I'll investigate that.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You're welcome :)

          1 Reply Last reply
          0
          • L Lost User

            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:

            B Offline
            B Offline
            BobJanova
            wrote on last edited by
            #5

            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).

            L 1 Reply Last reply
            0
            • B BobJanova

              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).

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups