Howto: Windows Hot Key – AutoHotKey

I was looking for something that would give me hotkeys to control iTunes on Windows XP at work.

When I step away from my desk I like to pause my music when I lock it. Also, I dislike having to navigate to iTunes to change the song or adjust the iTunes volume.

I found AutoHotKey which has a scripting language, active forum and licensed under GPL.

So I have Windows Key + space bar bound to play/pause and the arrow keys mapped just like they are in iTunes. I also have Windows Key + G mapped to Google and Windows Key + N mapped to my notes.txt file for quick ideas.

This script isn’t perfect, it just maps the key presses into iTunes, so it is possible to be moving the cursor through playlists rather then changing the volume. There are more complicated scripts for iTunes control, but this works well for me for now.

I took this from the AutoHotKey forums, thanks to the original author:

#NoTrayIcon
#SingleInstance force

#right::
DetectHiddenWindows, On
;WinGet, active_id, ID, ahk_class iTunes
ControlSend, ahk_parent, ^{right}, iTunes ahk_class iTunes
;MsgBox, The active window's ID is "%active_id%".
DetectHiddenWindows, Off
return

#left::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{left}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return

#down::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{down}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return

#up::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{up}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return


#space::
DetectHiddenWindows, On
ControlSend, ahk_parent, {space}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return

#i::
DetectHiddenWindows, On
IfWinActive, iTunes ahk_class iTunes
   WinMinimize
else
   Run %ProgramFiles%\iTunes\iTunes.exe
DetectHiddenWindows, Off
return

#g::Run www.google.com

#n::Run "C:\Documents and Settings\Gordon Turner\My Documents\Documents\@notes\notes.txt"

#s::Run http://del.icio.us/GordonTurner67/speed-dial

Update:

I added another hotkey to check to see if Firefox is open (if not, it opens it) and then create a new empty tab:

#t::
IfWinExist ahk_class MozillaUIWindowClass
{
   WinActivate
}
else
{
   Run C:\Program Files\Mozilla Firefox\firefox.exe
   WinWait  ahk_class MozillaUIWindowClass
   WinActivate
}
Send, ^{t}
return

Comments are closed.