Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jackb602

macrumors newbie
Original poster
Jul 23, 2002
8
0
Chicago
I know close to nothing about programming, but I'm looking for help on writing what I think would be a very basic program or script. I'd like the program to simply keep track of how long a given application is active. For example, let's say I have Word, Mail, and Photoshop open and I'm using Mail at the moment. The app would start a timer as soon as I open or switch to mail. When I switch to Word, the Mail timer would stop and a Word timer would start. At the end of the day, the app could display a simple report showing how much time I spent in each app. Of course, all of this would happen automatically in the background so I wouldn't have to constantly be keeping track of time.

Is this something that could easily be done in AppleScript or is it not as simple as I think it is? I wouldn't mind taking it on as a learning project, but if it's beyond my abilities, I'd consider hiring someone to write it. How difficult does this sound, and where would you recommend I start to learn more about how to accomplish this? I'd appreciate any thoughts.

Thanks,
Jack

p.s. I have tried a demo of TaskCapture, but it only seems to work with certain apps.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I'm not sure you can do this with AppleScript. I think you might be able to register for a notification from the system when the key app changes in Cocoa. Timers are inefficiant. Simply recored each time the key app changes then add up the time differences at the end of the day. I'll see if I can find out about the system notifications. If it looks easy I might be able to knock something up in a couple of days...
 

Jackb602

macrumors newbie
Original poster
Jul 23, 2002
8
0
Chicago
robbieduncan said:
CocoaDev Discussion

Looks pretty easy. Give me a couple of days to get something hacked together (in my spare time). I'll release as a GPL app. Sound OK?

Robbie,

Thanks, that would be brilliant! If you release it under GPL, that means the source code is publicly available right? That would be an interesting way for me to learn a bit about what the program does. Thanks so much for your help!

Jack
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Jackb602 said:
Robbie,

Thanks, that would be brilliant! If you release it under GPL, that means the source code is publicly available right? That would be an interesting way for me to learn a bit about what the program does. Thanks so much for your help!

Jack

Yes, releasing under the GPL means that the source code is publicly available and anyone can alter it. I'm probably not going to get much done on this tonight as it's 11pm already and I've been having a BBQ in a park and drinking a few beers :)
 

Jackb602

macrumors newbie
Original poster
Jul 23, 2002
8
0
Chicago
robbieduncan said:
Yes, releasing under the GPL means that the source code is publicly available and anyone can alter it. I'm probably not going to get much done on this tonight as it's 11pm already and I've been having a BBQ in a park and drinking a few beers :)

Cool, that will be a good way for me to get my feet wet and see how it's organized. One other feature that I thought would be useful is for the app to recognize when the machine has been idle for a while (i.e. no keyboard or mouse input) and stop all timers until the user returns. How hard would that be? Thanks again for helping out with this. No rush of course; enjoy the cookout!

Jack
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Jack,

I've just checked out your profile. Are you seriously on a very old Mac? All the code I write is Cocoa and in general targets the latest and latest-1 versions of OSX. So I'm talking about 10.4 and 10.3 at the moment.

What OS are you running?
 

Jackb602

macrumors newbie
Original poster
Jul 23, 2002
8
0
Chicago
robbieduncan said:
Jack,

I've just checked out your profile. Are you seriously on a very old Mac? All the code I write is Cocoa and in general targets the latest and latest-1 versions of OSX. So I'm talking about 10.4 and 10.3 at the moment.

What OS are you running?


Funny, I did used to use an 8600, but that was a long time ago. I hadn't even looked at my profile. I'm running OS X 10.3.9 on a Dual 1GHz G4. Not the fastest machine out there, but it does the job.

Thanks,
Jack
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Jackb602 said:
Funny, I did used to use an 8600, but that was a long time ago. I hadn't even looked at my profile. I'm running OS X 10.3.9 on a Dual 1GHz G4. Not the fastest machine out there, but it does the job.

Thanks,
Jack

OK cool. Hopefully I'll have a basic demo running later today. I was building for 10.4 using the Universal SDK (PowerPC & Intel) but I'll switch that to 10.3 (no great loss right now).
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
TimeWaster 0.0.0

This is mostly just a work in progress. It will improve! But the basic functionality works (check the Window Menu).

Edit to add: The name is not meant to imply anything about the original poster! It just seemed like a snappy and appropriate name. Honest!
 

Jackb602

macrumors newbie
Original poster
Jul 23, 2002
8
0
Chicago
robbieduncan said:
TimeWaster 0.0.0

This is mostly just a work in progress. It will improve! But the basic functionality works (check the Window Menu).

Edit to add: The name is not meant to imply anything about the original poster! It just seemed like a snappy and appropriate name. Honest!


Hey, I like the name! It cracked me up. I've just downloaded it and I'll take a look at it. Thanks again for your help!

Jack
 

Jackb602

macrumors newbie
Original poster
Jul 23, 2002
8
0
Chicago
Robbie,

I've installed TimeWaster and set it as a Startup Item. I then quit all my apps, logged out and back in. But the two windows don't show anything. Is there anything else I should be doing?

Thanks,
Jack
 

takao

macrumors 68040
Dec 25, 2003
3,827
605
Dornbirn (Austria)
Jackb602 said:
Robbie,

I've installed TimeWaster and set it as a Startup Item. I then quit all my apps, logged out and back in. But the two windows don't show anything. Is there anything else I should be doing?

Thanks,
Jack

same here neither window shows anything ...

did it work on yours robbie ?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
The windows won't show anything till you switch to another app (i.e. not TimeWaster). for the first time. It works fine on my machine (OSX 10.4.1).

Are you both on 10.3.9? It is possible that the Carbon calls to get the app get notified on application switching don't work on older OS versions (although the reason I went with these is that they are documented and the only Cocoa way is undocumented and does not work on 10.4).

I did notice that it did not catch Dashboard being activated.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I have attached a screenshot of it on my machine.
 

Attachments

  • TimeWaster.png
    TimeWaster.png
    71.4 KB · Views: 129

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Total bummer. I've just copied the built app to my Mac Mini (which is still on 10.3.9 as I've not got round to upgrading it yet) and it didn't work :( Looks like I need to use different methods to trap the events on different operating systems.

I'll look into it over the next day or two and post back once there is a version that works on 10.3.9 and 10.4.1.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
New version posted (at same URL as above). It works for me on 10.3.9 and 10.4.1 :)

Yay!

Note that I did not bump the version number and that the Timeline window is now there but the custom view does not do anything. Take this as a feature to come!
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
TimeWaster has gone 0.1.0 (initial release). Product page here. Listing submitted to VersionTracker. There are still bugs and unimplemented features (as noted in the bug list in the app). I will be updating this app over time as I fix the bugs an implement the missing features.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.