sachleenblogprojectsabout me

back How I use AutoHotkey

I've been using AutoHotkey (AHK) for a while now as a keyboard shortcut app and it's working really really well for me so I thought I'd share. If you don't know what it is, AutoHotkey allows you to write scripts to automate tasks on your computer. I mainly use it for doing things when I press certain keys on my keyboard but you can make it do a lot more.

Here's a rundown of the things I use daily with AHK. I keep everything in one file so all of these features are available from just one executable that starts with Windows. If I need to add or modify a feature, I just modify the source and recompile. I always hated having a programming running all the time for the smallest features.

Loop
{
    sleep 1800000
    TrayTip, Take a break!,`n,0, 1
}

First off we have a loop that shows a balloon tooltip in the notification area every 30 minutes (1800000ms) telling me to take a stretch break. I went through a few dedicated programs before writing my own super simple solution.

;Toggle mute - Scroll Lock
ScrollLock:: Send {Volume_Mute}

This one-liner sets the function of the Scroll Lock button on my keyboard to mute/unmute volume. (The mute button on my laptop doesn't work, too lazy to find the right drivers) Also, if you're unfamiliar with AHK, the semicolon (";") is used to comment out lines.

;Toggle Always On Top - Ctrl Shift Space
^+SPACE::  Winset, Alwaysontop, , A

Another one-liner, see how simple this is? This one toggles the currently focused window's state between normal and always-on-top. Used to use a dedicated app for this, now it's just one line in my AHK script.

PRINTSCREEN:: Send #+S

I started using windroplr recently (great app) but didn't like having to press WIN Shift S shortcut to take and upload screenshots. Simple enough, just map the Print Screen key to WIN Shift S.

;Paste as plaintext - Ctrl Shift V
^+v::
    ClipSaved := ClipboardAll
    clipboard = %clipboard%
    ClipWait, 2
    Send ^v
    Sleep, 1000
    Clipboard := ClipSaved
    ClipSaved =
return

This one is a little more complex than the others. I use Pidgin for IM and whenever I paste some text into the chat window, the formatting of all of my messages changes to the formatting of that text. So annoying! A little Googling led me to this snippit. This assigns Ctrl Shift V shortcut to strip the text in the clipboard of any formatting and paste. Ctrl V works as usual.