Counting Mouse Clicks With Clickr

Wednesday, May 09, 2007

 I recently found myself wondering how many times a day I click the mouse. A quick Google turned up a few promising tools, but none of them were really what I had in mind. As a big fan of keyboard shortcuts, I wanted to know not only how many times I click the mouse but also how many times I click the mouse per application, the idea being that I could use this to figure out which application's shortcuts might be worth learning. With this in mind, I present Clickr. Here's what it does:

  • Counts the total number of left, right and middle (wheel) mouse clicks.
  • For each click logs either the description of the executable (default) or window title of the current foreground window. (Logging the description makes the most sense I think. Run two instances of Clickr and log both if you like.)
  • Displays the total clicks, clicks per window and the date and time logging began on a Windows Form.
  • Minimizes to the notification area (system tray).

Clickr Screenshot Most of this was put together using standard .NET 2.0 Windows Forms stuff. The key to making it work was the fact that you can use .NET to set a low level hook to monitor mouse events, and from there it only takes a little more Win32 work to get a handle to the foreground window and ultimately the window title or executable description. Once I had this working, I added a couple of optimizations to firstly cache the descriptions (which are too expensive to fetch for every click) and secondly ensure that I'm not trying to update the form when it's minimized, as this is also fairly expensive and clearly not very sensible.

I'm not sure anyone else will find this particularly useful but I had fun putting it together and so I thought I'd share it here. There's a link to the executable at the bottom of this post, and although it's not exactly production quality I'll put the source code up as well. It should run on Vista and XP (with the .NET 2.0 Framework) but I've not tested it beyond running it on my machine for a few days, so you mileage may very well vary.

Clickr_1_0.zip
Clickr_Source_1_0.zip

3 Comments | .NET 2.0

Comments

Chris said... Ive been running this for the last 13 minutes and I'm already up to 178 clicks. Unbelievable.

I plan to keep clickr running through the next 4 days while I'm on with this project, it'll be interesting to see how much time is wasted on the mouse...

189 now. I got distracted midway through typing!!

Friday, May 11, 2007

Marilia said... Hi, did you find a program like this for MAC?

Wednesday, March 05, 2008

Aidin said... Thank you very very much. I enjoy it alot. I wish I could kiss you for that. I was thinking about that before and I just wanted to count it myself but it was impossible. So I think it is useful for the physicians, both physical and mental ones to have their patients examined?! and for myself to make ready myself for the shutdown day idea!

Tuesday, July 08, 2008

Comments have been closed on this topic.