The other day, I came across a problem I frequently seem to encounter. I had a group-chat in Skype that I wanted to follow, but not necessarily contribute much to, and due to how often it was updating, it was getting annoying to have to constantly stop typing in my full-screen IDE and alt-tab back to Skype. I realized that it would be much more efficient if I could somehow temporarily designate that Skype window to always stay on top of the screen, the same way Task Manager does. That way I could be working away in my IDE, and when there were new messages in Skype I simply had to glance over, rather than alt-tab.
Naturally, I assumed this was a problem that was already solved, and a little Googling led me to a handy always-on-top toggle script that is activated using a hotkey. Perfect! Download, install, run, and within a few seconds I had my desired functionality… only the hotkey that the script uses to toggle the always-on-top property is ctrl-space, the same shortcut used for the absolutely-necessary auto-complete feature in Eclipse.
The script doesn’t provide any means for changing the hotkey, so I had to get a bit more creative. I set out on what I thought would be the difficult quest of figuring out how this script was made and re-making it with a different hotkey (I ended up using caps-lock). To my utter disbelief, it only took about five minutes. There were a few reasons why this was so easy to do, which I’ll get to in a moment, but first here is the script in case it might be useful to anyone else:
No, I didn’t test it in Vista or Win7. Yes it might still work; please let me know if you try it. If you’re curious about doing this in linux or OSX, you’re on your own, but I’d love to hear about that too :~)
Now then, the rest of this post will be about why this was so easy to do, with a few lessons about good software tool development practices. For starters:
It helps when things are open-source.
That handy page I mentioned earlier was kind enough to mention that their ctrl-space script was made using a tool called Autohotkey, which I’d never heard of, and that it was only one line, which they provided:
^SPACE:: Winset, Alwaysontop, , A
So I downloaded Autohotkey, and braced myself for the impending learning curve. Fortunately, I was in for a shock:
Autohotkey is an incredibly intuitive tool.
It literally took me under two minutes to install Autohotkey, grok how it worked, and recreate the script with the line of code above. I credit this entirely to Autohotkey’s development team for putting together a really easy-to-use slice of utility software. Here are the things it got spot-on:
It installs an editor and a converter. No sense trying to put these two functions together into one larger (and surely more complicated) application, and their respective purposes are obvious right from their executable names.
The editor literally doesn’t let you do anything other than type out .ahk files. This is key; don’t let me fret over which filetype to save in, force me to use one option that is guaranteed to work.
The converter has a dead-simple UI. A field asking for an .ahk file, a field for specifying the path for the .exe, and a giant button that says “Convert”.
Without reading any documentation or having any experience with this tool, it took minutes to accomplish a simple, but specific task. All software should work like this. I shouldn’t have to read any documentation to figure out how to use the core feature of your application. That said:
Autohotkey’s documentation is excellent, from what I saw.
I say “from what I saw” because I didn’t have to look at very much of it (which, again, is the way it should be). All I wanted to do was change the hotkey I already knew about from ctrl-space to something more convenient, so I pulled up the AHK docs, which had a very convenient Hotkey pages summarizing exactly what I wanted to know (and nothing more).
All I had to do was skim through this one, short page to find a better hotkey. About two screen-lengths down I saw a note on how to disable caps-lock (this is perfect; I never use caps-lock—ever—and it’s a nice big key that’s easy to hit). Even though the docs actually use num-lock in their welcomely-concise code-sample, I was able to take a pretty reasonable guess at the syntax for disabling caps-lock and how to override it to run my always-on-top line. Back in the editor, I made the small change, switched back to my converter and hit that big, impossible-to-miss convert button again (without re-entering my filenames) and… it worked on the first try! I was speechless — five minutes.