How to adjust the volume with a keyboard shortcut

Update: Here’s an easier way to do this.

This is the first of a series of instructional screencasts I’ll be creating. I was inspired by Mouser’s 30 days of screencasts to create a few of my own.

This one teaches you how to create a global keyboard shortcut to turn the volume up or down, toggle mute, minimize a window, shutdown, restart, log off, make the computer say the text in the clipboard and empty the recycle bin.

Your keyboard may have buttons for this purpose, but these shortcuts are portable to any computer (XP/Vista and Windows 7), including my laptop.

Freeware genius wrote about a few utilities to change the volume, but I prefer AutoHotkey because I already use it for shortcuts and text completion. My resident Autohotkey script uses about 4MB of RAM and adding a few extra shortcuts doesn’t change that. Running a new utility would.

I realize the text in the video is a bit hard to read. I’ll work on making it easier to read for future screencasts. The version I uploaded to YouTube was hard to read, but the same video uploaded to Vimeo (which is now below) looks great.

Here’s the AutoHotkey script I used.

; Minimize active window with Ctrl-Alt-m
^!m::WinMinimize,A

; Send command to nircmd
runNircmd(args)
{
  Run %A_WorkingDir%\..\..\utils\nircmd\nircmd.exe %args%
}

; Volume control (turn volume up and down and toggle mute)
^!Up::runNircmd("changesysvolume 5000")
^!Down::runNircmd("changesysvolume -5000")
^!.::runNircmd("mutesysvolume 2")

; Say what's in the clipboard
^!]::runNircmd("speak text ~$clipboard$")

; Power commands
^!+r::runNircmd("initshutdown ""Rebooting in 10 seconds"" 10 reboot")
^!+s::runNircmd("initshutdown ""Shutting down in 10 seconds"" 10")
^!+q::runNircmd("abortshutdown")
^!+l::runNircmd("exitwin logoff")

; Empty the recycle bin
^!+b::runNircmd("emptybin")