How-To: Control iTunes From Anywhere (AutoHotKey)
by Omni on Mar.09, 2009, under How-To Guides, Useful Programs
You may be an avid fan of iTunes, using it for its MP3 indexing and playback capabilities. However, it can become cumbersome to have to switch back to the window just to skip a song in shuffle playback mode. I too have had this problem, and thankfully, came across an ingenious solution after hours of scouring the internet.
Allow me to introduce you to AutoHotKey. AutoHotKey (AHK) is a small program that let’s you create your own programs, macros, and scripts. You can record and send keystrokes, and even tap into the Windows API with AHK. (This means you can program things easily, as you will in this guide.) Keep reading for the full guide on how to get AHK set up, and get the iTunes Controller script installed.
- Visit the AutoHotKey website and download the latest version, and install it (if it is not already installed on your system).
- Once installed, open up a new text document (NotePad works perfectly) and copy/paste the code given at the end of this post into the document.
- Save the file with the extension of .ahk (deleting the .txt, if it’s there). So, for example, your file may be called “itunes.ahk”.
- Confirm that it is working by opening iTunes, double clicking on itunes.ahk (or whatever you named your script), and pressing the hotkey for Play, Windows+/
- If you want to add the AHK script to run on startup (so that you don’t have to manually load it every time you turn on your computer), right click on your .ahk file, and go to Create Shortcut.
- Assuming you are running Windows XP, place the shortcut you just created here: “C:\Documents and Settings\<User>\Start Menu\Programs\Startup”. For future reference, any shortcut you place here will automatically load upon startup. You can place as many shortcuts as you want, but just remember that your startup time will slow down depending on how many programs you have running on startup.
- You are good to go! Check out the available hotkeys that you can use for iTunes below. (The Windows key is found between Alt and Control on traditional keyboards, and generally opens the start menu when pressed alone. Take all characters EXCEPT for the plus sign (+) literally; the plus sign indicates that the buttons must be pressed simultaneously.)
- Startup iTunes / Switch to iTunes: Windows + \
- Play / Pause: Windows + /
- Next: Windows + .
- Previous: Windows + ,
- Volume Up: Windows + ;
- Volume Down: Windows + ‘
- Song Preview (changes song every 10 seconds): Windows + =
- End Song Preview: Windows + -
You can also make edits to the script to meet your demands. AHK has wonderful documentation on how to use it found here.
Below is the iTunes Controller Script, written by Polyphenol:
; iTunes Anywhere
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Polyphenol <myemail@nowhere.com>
;
; Script Function:
; Control iTunes from anywhere with hotkeys
;#NoTrayIcon
#SingleInstance force
DetectHiddenWindows, on#\::
IfWinNotExist, ahk_class iTunes
{
Run %ProgramFiles%\iTunes\iTunes.exe ;launch program
return
}IfWinExist, ahk_class iTunes ; toggle minimize/restore
{
IfWinNotActive ; restores window
WinActivate
Else
WinMinimize ; minimizes windows
return
}#.::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{RIGHT} ; > next
return#,::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{LEFT} ; < previous
return#/::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, {SPACE} ; play/pause toggle
return#;::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{UP} ; vol up
return#’::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{DOWN} ; vol down
return#=::
SetTimer, songpreview, 10000 ; change song every 10 sec
songpreview:
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{RIGHT}
return#-::
SetTimer, songpreview, Off
return;endofscript
Did you like what you read? Be sure to get the latest posts emailed straight to you or subscribe to our RSS feed for the latest posts.
March 24th, 2009 on 6:04 pm
wow Autohotkey sounds really useful