This project is read-only.
Project Description
Reusable .NET component with full source to detect idle/active time by checking keyboard/mouse input. Comes bundled with basic proof-of-concept app. Great for seeing how active you really are!


Have you ever wondered how much you work in a day? You might keep track of when you start and stop, but do you really keep track of every interruption? In this project, learn about how to keep track of user activity and see how to build a component to add to the Visual Studio toolbox.

I’ve built time-tracking applications before, but I’m not that great at using them. It seems that I just can’t remember to pause and resume the timer consistently enough. If I keep it logged in while I run to the store, it’s not all that accurate!

This project uses the Win32 API call that you can use to get a handle on user activity. To be more useful, I decided to also add the necessary glue to expose the features as a component to add to your applications from the Visual Studio toolbox, much as a Timer or StatusBar control is used. This makes it easy to wire up the properties and events with less coding later.

This has been tested all the way up to Windows 7.


Just run the app and it will start measuring the total time that you are active. The options window lets you choose how long of being idle counts for being idle. It defaults to 60 seconds. This is important, because it takes time to read an email or web page, or just to brainstorm. With a number too low, it will count you as idle if the keyboard and mouse aren't active, even if you are!


This was originally published with the MSDN Coding 4 Fun article ActivityMonitor.

Last edited Apr 9, 2009 at 9:09 PM by atkulp, version 2