Blog Archives

how to log time spent using apps

My_Work_Desk_by_animae_rian

If you are looking for a way to log how long a user (such as yourself!) is spending time in a given app, or to collect data on your pattern of work over time, this little script should do the trick.

Update: I’ve recently written a Cocoa-app that includes this function. Take a look at OSXClock here. 🙂

It will create and keep a running log file (called ‘log.txt’) on your Desktop indicating which apps have been in focus on your machine and for how long each time. This could be ideal if you want to keep track of how long you spend working on a particular project either for billing a client or just for checking your own productivity.

How to use:
Open AppleScript Editor and paste the text below into the Editor window. Click the ‘run’ button. When you’ve had enough click the ‘stop’ button. It would be possible to automate running and stopping this, but I’ll leave that for the comments or maybe a later post.

*Note: be sure to click out of the app you’re using and activate Finder before you put the machine to sleep, otherwise the log will include the sleep time in the app’s duration

(see the script on pastebin)

--start of script
set front_app to (path to frontmost application as text)
set _start to current date

repeat
delay 5
set current_app to (path to frontmost application as text)
if current_app is not equal to front_app then
set _stop to current date
do shell script "echo " & front_app & " was active from " & _start & " until " & _stop & " >> ~/Desktop/log.txt"
set front_app to current_app
set _start to current date
end if
end repeat
--end of script

Example log:
You will see the log looks something like this:

Seagate DP1:Applications:Utilities:AppleScript Editor.app: was active from Monday, 17 June 2013 17:20:30 until Monday, 17 June 2013 17:20:35
Seagate DP1:Applications:Adobe InDesign CS6:Adobe InDesign CS6.app: was active from Monday, 17 June 2013 17:20:35 until Monday, 17 June 2013 17:21:15
Seagate DP1:Applications:TextWrangler.app: was active from Monday, 17 June 2013 17:21:15 until Monday, 17 June 2013 17:21:25
Seagate DP1:Applications:Adobe InDesign CS6:Adobe InDesign CS6.app: was active from Monday, 17 June 2013 17:21:25 until Monday, 17 June 2013 17:24:46
Seagate DP1:Applications:TextEdit.app: was active from Monday, 17 June 2013 17:24:46 until Monday, 17 June 2013 17:26:26
Seagate DP1:Applications:Safari.app: was active from Monday, 17 June 2013 17:26:26 until Monday, 17 June 2013 17:45:03
Seagate DP1:Applications:Adobe InDesign CS6:Adobe InDesign CS6.app: was active from Monday, 17 June 2013 17:45:03 until Monday, 17 June 2013 17:46:03
Seagate DP1:Applications:TextEdit.app: was active from Monday, 17 June 2013 17:46:03 until Monday, 17 June 2013 17:46:13

On subsequent runs, you can keep the same log (the script will continue to add to the log on each run) or roll it over by renaming the log.txt on the Desktop and saving it off to somewhere else. If you rename or move the log.txt, then the next time you run the script, it will create a fresh log.txt on your Desktop automatically.

🙂



Featured picture: My Work Desk by ~RianGonzales

Camtasia 2 reviewed



I’ve been a long time user of TechSmith’s Camtasia screen capture software, primarily for two reasons: ease of use combined with a rich set of editing features. Camtasia for Mac 2 strengthens this product in a number of significant ways although there are still some usability issues that need addressing, as well as room for further improvements in the feature set. In this review, I’ll walk you through what Camtasia has to offer as well as indicate the kind of uses where it excels as an aid to the technical communicator. Read the review…

%d bloggers like this: