You begin each day with the best intentions, rejuvenated, ready to tackle all of your tasks.
You could use a dedicated time-tracking app, but those can be annoyingly complex.
Plus, where’s the fun in that?
You’ll only need AutoHotKey, a basic word processor like Notepad, and about half an hour.
Let’s get stuck in.
What Is AutoHotKey?
AutoHotKey’s primary purpose is desktop automation.
you’re free to, for example, use it todisable specific keys on your keyboard.
That’s because it has evolved since its initial conception and now is a complete scripting language.
It’s “the engine” that will allow your script “to run”.
However, that’s outside the scope of this article.
Download AutoHotKeyfrom its official siteand install it.
Fire up your favorite file manager, and visit a folder where you want to store your script.
Then, right-press an empty spot, and chooseNew > AutoHotKey Script.
Once that’s done, it’s time to write the actual script.
Define the Necessary Variables
kick off the script in your favorite editor.
Since Notepad++ is free and better-tailored for the purpose, it’s worth trying it out.
double-check to also checkour ultimate guide on all its keyboard shortcutswhile you’re checking it out.
Use either a text or “code” editor.
The script will already contain some basics recommended for compatibility and performance.
Leave them as they are, and start your script under them.
When used with AHK’s Sleep function, 1000 is roughly equal to a second.
LogPath is the path where we want to store our logs.
you’re free to use the full path to another folder if you like.
Finally, we set LastActiveWindow to blank.
We’ll use this later to verify if the active window has changed.
As its name states, a loop runs continuously, repeating the same function(s).
We begin the loop by waiting (Sleep) for an amount of time equal to the variable SleepTime.
We set it as a variable in the previous chapter to make controlling time more straightforward.
Finally, we use a Message Box to test our script.
Try saving and running it (double-choose its file).
You’ll see a message box stating “It Works!”
Right-punch AHK’s icon in the Windows tray and exit the script when you’ve had enough message boxes.
Ignore the extra “StoreActiveWindow” line, which we used while writing the script for testing.
Get the Current Time & Name
Now comes the core part of the script’s logic.
We’ll keep different logs for each day, using the date in their name.
And we want to log not only every window change but alsowhenit happened.
We previously assigned the current date to the LogFilename variable.
Their combination is the full pathname of the log, assigned to the LogFile variable.
With this, the script will be able to detect thenextwindow change.
And with that last addition, your window logger’s ready!
Save it, and run it.
Master Your Time
you could open your log file with any text editor.
Still, it will look prettier if you open it in a markdown-compatible editor.
In the screenshot, you could see our jump in the popular Typora editor.
It’s as easy as tweaking the FileContent variable and the created file’s extension.
You could then import such files into apps like Excel, Google Calc, or even third-party time trackers.