Hacker News new | ask | show | jobs
by wink 3121 days ago
I, too, wanted to start tracking this a bit but

a) didn't want stuff to be uploaded anywhere

b) didn't want to test a lot of apps

c) am always up for a challenge

So 2 weeks ago I dug out my long-forgotten knowledge about WINAPI and wrote something in Rust. It's an MVP - it queries the active window every second and writes a bit of info to a logfile in JSON format. Then I can run a python script on the daily log and analyze it. It's been fun, but you instantly notice a few things:

a) using a "window changed" hook would be better, but mine's good enough for now, but this prepared

b) idle times are important. Don't leave the computer and then wonder about off times. Current workaround: focus the media player window that's usually not really active

c) dual monitors are really hard. There's 2 windows open - one on each monitor, only one will be tracked.

d) Everything is hard, when I'm listening to a podcast during some other task that doesn't need much concentration, this won't be tracked.

e) actual quality of the data. On the one hand I'm simply not interested in adding all my browser history to this via window titles. On the other hand, maybe you want finer-grained tracking. Same with songs played, videos watched for example. Mayyybeee it could make sense tracking source code files in your editor, but I think that's too finegrained. browser vs editor is good enough for me right now

1 comments

Yes, tracking multiple activities at the same time is too hard. I just stick to tracking the focused window.

On macOS I use accessibility API to read content on the screen, including address bars in browsers. But a browser extension sending URLs to your app on localhost can work too.