AutoHotKey, the magic keyboard

Frankie
3 min readDec 2, 2022

--

Originally published at https://wasteofserver.com on December 2, 2022.

If I were Microsoft, I’d buy AutoHotKey just to natively integrate it into Windows.

AHK (AutoHotKey) is one of those tools that, once configured, you won’t notice. Until it’s missing. Then you’ll really value it.

I’ve recently read this article about creating a Python script that makes you always online. It sprung a long-lost memory of doing something similar for a friend with the same end result; keeping the computer awake.

He wasn’t trying to cheat company surveillance but, then again, work from home was not really a thing back then. He was trying to reap credit in an online game.

As a firm believer in code by example, I’ll leave you with two scripts that I currently use, and then one to keep the computer awake. You just have to install AutoHotKey, save the code into a file, give it the extension *.ahk and run it.

ThinkPad X1 Yoga and the missing key

I was a long-time user of Microsoft Surface Pro.

For me, it strikes the perfect balance between a laptop and a tablet. However, my equipment tends to last so batteries eventually become the bottleneck.

Last summer, replacing battery, the screen shattered. Vowed to never again get equipment that didn’t have easy replacement parts so I bought myself a ThinkPad. While X1 Yoga folds all the way to make it tablet-y, it is definitely more laptop than tablet. And, being a computer, it’s definitely missing one key. The menu key.

AutoHotKey to the rescue!

#NoEnv ; Performance and compatibility with future AHK releases #Warn ; Enable warnings to better debug errors SendMode Input ; Better speed and reliability SetWorkingDir %A_ScriptDir% ; Consistent startup dir ; maps right Ctrl key as the "Menu" Key RCtrl::Appskey

ThinkPad has two Ctrl keys and no Menu key. This fixes it!

WASD has some of the best keyboards I’ve experienced.

I’ve got two. One at home and another at work. I would even invest in the CODE Keyboard, a WASD collaboration with Jeff Atwood, if they would support the pt-PT layout.

But, as great as the keyboards are, they’re missing that top row with the media player keys that was popular in the 90s.

Honestly, it’s a good thing they don’t have that row anymore, but the keys not being there is no excuse for you not to be able to change volume without leaving the keyboard.

AutoHotKey to the rescue!

#NoEnv ; Performance and compatibility with future AHK releases #Warn ; Enable warnings to better debug errors SendMode Input ; Better speed and reliability SetWorkingDir %A_ScriptDir% ; Consistent startup dir ; maps navigation keys to Media keys with modifier ; Ctrl + Insert ^Insert::Send {Media_Play_Pause} ; Ctrl + Home ^Home::Send {Media_Stop} ; Ctrl + PageUp ^PgUp::Send {Volume_Up} ; Ctrl + PageDown ^PgDn::Send {Volume_Down} ; Ctrl + Del ^Del::Send {Media_Prev} ; Ctrl + Del ^End::Send {Media_Next}

Maps the block of Keys known as “Navigation Keys” to the Media Keys with Ctrl as a modifier

Press F15 every 108 minutes!

On the TV-series Lost, they had to press a red-button every 108 minutes; or-else! On our specific case, we know exactly what happens if nothing is pressed, the computer idles.

I picked F15 as though that key is present in most keyboard mappings, almost no keyboard has it therefore, it's very unlikely that it will affect your work in any way.

Which means you can use the system at will, with AutoHotKey auto-pressing F15 for you every X seconds, without noticing.

#NoEnv ; Performance and compatibility with future AHK releases #Warn ; Enable warnings to better debug errors SendMode Input ; Better speed and reliability SetWorkingDir %A_ScriptDir% ; Consistent startup dir ; presses F15 every 10 seconds to keep computer awake Loop { Send {F15} Sleep 10000 }

If people in Lost had AutoHotKey!

Any time-saving AHK scripts to share?

Post them in the comments!

Originally published at https://wasteofserver.com on December 2, 2022.

--

--