Alex Rivera | Logout

How to calculate the total time a user spending on an application?

Asked 2011-06-24T17:45:21.500
17

I want to create an application that able to calculate the total time the user (i.e. myself) spent on a particular application, for example Firefox. And this application should display warning message if the user spent a lot of time on Firefox (for example 1 hour or more)

Reason: I'm a VB.NET developer. During my working hours, my main tool is Visual Studio and I suppose to do coding. But I need Firefox occasionally to access internet (particularly SO and other sites) to find solutions for my programming problems. The problem is I addicted to SO and SO sucks my time for hours until I have forgotten that I suppose to continue coding and not browsing the SO site.

My question: How to calculate the total time a user spending on an open application like Firefox?

Update:

I need to play a song as warning message to myself if I stay too long on Firefox. My intent is to create a winform or windows service to achieve this

Edit
Report

1 Answer

3

There are many tools to do this like RescueTime etc... but you could use some .net code to knock up an approximation quite quickly.

You would need to poll the list of processes at some given interval,

psList = Process.GetProcesses() 

You could use the starttime property and the main window title to get information about each process. I am not sure how to tell which one is active or not.

answered 2011-06-24T17:51:50.913

Your Answer