Global Hotkeys for iTunes
Posted by Stefan on May 28, 2009
I always had a love/hate relationship with iTunes. I started using it a couple of years ago when I received an iPod Nano as a present for my birthday. I was immediately hooked by the library and podcast management features.
But iTunes can be very annoying sometimes. With each new version the application speed seems to decrease, startup times are bigger and program features seem to randomly disappear and reappear. For example the update from version 7 to 8 removed among others all the podcast management options and the ability to import songs as mp3 files. The latter magically appeared back in version 8.1. Also there is no way to control the player while other programs have focus using some system-wide key combination and there are no notifications when songs change.
In spite all this I still use it is my default music player because it’s the best way to manage my iPod and it’s one of the best podcast managers out there. And a few other cool features like iTunes U and Audible.com support.
Although the extensibility model for iTunes is not great, I found a plug-in that “displays a popup notifier window with track information (art cover, song name, artist, album)” each time a new track is played and a few applications that add global hotkeys support. I used for a while Jacob Hickman’s application but this is an external application, not an iTunes plug-in so every time you want to use it you have to remember to open it. What I really wanted was something similar with the iTunes toaster plug-in that added global hotkeys to the player.
And so iTunes Global Hotkeys Plug-in for Windows (ighp) was born. Ighp enables the user to trigger different actions using predefined shortcuts even if the player is minimized or hidden, just like the external apps do. The advantage is that it is automatically started and stopped with the player. You do not have to worry about anything else.
To achieve this, ighp uses a technique similar with the one used by the toaster plug-in. iTunes supports only visual plug-ins so ighp uses iTunes Visual Plug-ins SDK to make the player think it is a visual plug-in.

After the plug-in is loaded, it uses the iTunes COM for Windows SDK to control the player, just like the external applications do. The following actions are supported:
| Action | Description |
|---|---|
| PlayPause | toggle play/pause |
| NextTrack | advance to the next track in playlist |
| PreviousTrack | go back to previous track in playlist |
| ToggleRandom | toggle random on/off |
| ToggleRepeat | toggle repeat on/off |
| SongRatingClear | clear rating for the selected song |
| SongRating1 | set rating to one star |
| SongRating2 | set rating to two stars |
| SongRating3 | set rating to three stars |
| SongRating4 | set rating to four stars |
| SongRating5 | set rating to five stars |
| ShowHide | minimize/restore player window |
| VolumeUp | increase volume level |
| VolumeDown | decrease volume level |
| ToggleMute | toggle mute/unmute |
| OpenSettingsFile | Open settings file in notepad |
| ReloadHotkeys | Read the configuration file and reload the hotkey bindings |
By default, only two actions are configured: OpenSettingsFile (Ctrl+Shift+P) and ReloadHotkeys (Ctrl+Shift+R). You can configure more actions using the instructions on the project’s page and then you can reload the configuration to activate the hotkeys. Here is an example of a typical settings file:
<hotkeys>
<hotkey action="OpenSettingsFile" key="P" control="true" shift="true" />
<hotkey action="ReloadHotkeys" key="R" control="true" shift="true" />
<hotkey action="PlayPause" key="Spacebar" alt="true"/>
<hotkey action="NextTrack" key="." alt="true"/>
<hotkey action="PreviousTrack" key="," alt="true"/>
<hotkey action="ShowHide" key="q" alt="true"/>
<hotkey action="VolumeUp" key="a" alt="true"/>
<hotkey action="VolumeDown" key="z" alt="true"/>
</hotkeys>
The latest release of the plugin can be found here. iTunes Global Hotkeys Plugin is released under the MIT/X Consortium License. Feel free to download the source code and if you fix a bug, or add a new feature, just send me a patch.