iTunes & Media Keys

I was really annoyed by something when I got a new Dell PC with XP Media Center Edition. The media keys on the keyboard (like Skip, Back, Play, Stop, etc) didn’t work in iTunes unless it was the active window. In contrast, they did work with Windows Media Player, even if it was minimized (of course).

Since this was wholly unacceptable, I decided to spend a few hours devising a workaround. The result was two programs: iTunesKeys and iTunesCommandPasser (I know, great names). Both are written in C#, using the COM provider built-in to iTunes.

iTunesKeys basically creates a global keyboard hook looking for one of the media keys to be pressed. When that happens, it fires an event and executes the iTunesCommandPasser with a command line parameter telling it to skip, go back, or whatever.

The reason this is in two parts is that you cannot have two things going on via COM at the same time, under the same process. Since I am using COM for the hook, and to pass commands to iTunes, the two pieces had to be split in half. There may or may not be a more elegant way to deal with this, but I didn’t spend much time working on it.

To use the binaries, put the two EXEs and one DLL in the same directory, and launch iTunesKeys.exe. I’ve noticed that it seems to crash if you start iTunesKeys before iTunes the first time, since it probably isn’t registering correctly. I’m going to look at fixing that.

Zips below contain both programs.
Source Code

Thanks to Dan Crevier at MSDN for discovering the COM abilities of iTunes.


155 Responses to “iTunes & Media Keys”

  • Thanks a million Andy! Works like a charm.

  • thank you so very much!!!

  • wow. the buttons didn’t always work until I met you. thanks

  • Thanks a lot. Good work.

  • Hey I was just curious if there’s anyway to get this to run at startup. I know there has to be a way to do it in windows even though the option isn’t in iTunesKeys. Its not just the fact that I have to manually start it but the task bar shows the icon and each time I have to hide it. Its not a bad icon I just like my task bar neat and clean. Thanks for the help and great work! Using it with iTunes and Vista home premium for those who keep track.

  • awesome. this is perfect for me. thanks a bunch.

  • Great program, except that it’s taking up 20,244k of memory on my system! Seems a bit much for a simple plugin, if you ask me. WinXP Pro, iTunes

  • Thank you SO much for this utility – having just upgraded to Vista I was distressed to find my G15 wouldn’t control my iTunes without it being the focus window. This simple utility restores the functionality I was used to previously 🙂

  • I’ve tried putting the two files and the dll in one directory however it fails to work, do you hvae a solution to this? would it be because i am using the most updated itunes?

  • So until recently the keys worked automatically with itunes even when unfocused, but since I upgraded itunes, it wasn’t working. This program fixed it! Awesome. Thanks.

  • Man, You realy did a great job, I was using the media buttons with itunes 6, now with itunes 7 don’t work anymore, but now with your program they works again!!

    Thank you very much.

  • Hey! I have read all the comments and no one seems to have my problem… The tool works perfectly. Its (again!) vista comming in the way to complicate simple things.
    After I run the tool, everytime I press one of the media keys Vista asks for permission to open/run a file. Even though i clicked the “dont ask again” check box (the text is something like that, you get the point) it keeps asking!
    Any thougts?

  • So, I’d been using this program for a couple months, and everything was working perfectly on my XPS M1210 w/ Vista Ultimate. And then about two weeks ago it just stopped working. I get prompts to “Allow/Deny”, and the program keeps failing with error “iTunesKeys.exe – Common Language Runtime Debugging Services. Application has generated an exception that could not be handled.”

    I LOVE this software, and will happily pay for the knowlegde of how to make it work for me again.

  • Terrific! Works great with my G15 keyboard regardless of what application is running in the foreground. You rock!

  • Wow, that’s incredible. Thank you so much!

  • Does not work on Vist abusiness, see comment #64.

  • kick ass man! working great on my dell e1705. thanks alot!! it was extremely annoying

  • Could you make a version that doesn’t show the try icon?

  • Its very sad that Apple must act this way towards its PC user base just because they wish to make PC’s seem inferior.

  • Thanks for this program ts small and quite memory intensive for such a small program but who cares it works. For people having problems try re-downloading the files. I cut and pasted the files into the itunes folder coz it seemed like the most logical place to put the three fles. Also follow what was written open itunes first then run ituneskeys.exe. That should do it. Also I am running vista so vista is not the cause for your problems.

    Jon, to auto start make a shortcut of ituneskeys.exe and cut and paste it into the startup folder in the ‘All Programs’ menu. Also to hide the taskbar icon right click on the task bar go to properties an in there somewhere you can tell windows to always hide the icon.

  • Thx a lot for this app! i’ve also installed vista and my g15 keyboard media buttons weren’t working anymore…
    your app has reenabled it in vista BUSINESS, beautiful!

    yours, shere

  • thanks a bunch mate!!
    anyone up for making a command prog-string to open itunes then the keysprog?

  • incredible just what I was looking for

  • I downloaded them, put the in the same dir, but when I click iTunesKeys it gives me an error saying failed to initialize. I have tried to re download it, and I do open iTunes first. Any help would be great, thank you. 😀

  • Wow, thank you, this has rescued me from a pit of frustration!

  • Dear Andy,

    After downloading your programs, I thought that this wouldn’t work. But I was wrong.

    I just got a G-15 keyboard, and it works beautifully. Thanks.

    – Mike

  • Well played, sir. This works like a charm with my new zboard.

  • HAHAHA, YOU LITTLE BEAUTY! worked a charm for my crappy acer aspire KU-0355 keyboard.

  • Does exactly what it needs to do. I’ll be putting this in my startup.

  • that was so easy! thank you for this amazingly simple and effective program. I’m using the new Dell Inspiron 531s just in case you were keeping track of that stuff.

  • This is a nice program. Thank you for sharing your work. Maybe I’m being picky but it seems to be a little slow to respond on my computer (around 1 sec). Any ideas. Running it on a Dell Precision M90.

  • thanks dude! works perfectly on my Vaio laptop, Vista Home Premium + iTunes 7.5

  • Awesome! What a simple fix… I have been dealing with this issue with my G15 Keyboard and iTunes for months. Thank you so much!

  • Just wanted to add another to the list of satisfied customers. Kicka$$!!!! let’s get married

  • Thank you so much! I’ve been looking for a fix since the media buttons stopped working after updating iTunes.

  • Thanks!

    Great stuff!

  • Oh My Gosh you are a SAVIOR!!! I LOVE YOU! Thanks sooo much! 😀

  • Love the idea of this but I get an error every time on my system. I make sure iTunes is running first, then start iTunesKeys.exe (have downloaded a few times and tried it in my documents folder and in program files). It starts up fine but when I push a media key I get the following error every time:
    iTunesKeys.exe – Common Language Runtime Debugging Services

    Application has generated an exception that could not be handled.

    Process id=0xa04 (2564), Thread id=0x11ac (4524).

    I am running Windows Vista Ultimate 32-bit on a Toshiba Satellite A130 laptop, iTunes version

  • Great work, media keys have been bugging me for months!

    Running a Dell XPSM1330 2.2Ghz with Vista Ultimate 32-bit, and the iTunesKeys works perfectly.



    Had been using Multi-Plugin, but it hadn’t been updated in forever (I think the last release was for iTunes 7.0.2)… It’s nice to have a fix that isn’t version-dependent!

  • Thanks

  • Great program, works smoothly on my Dell Inspiron 1720 with Vista Prem. Thank you for this wonderful program.

  • Ur a real saver, great saver, cant see y apple didnt think of it

  • You are amazing……a genius. Just wondering. What do you get out of it?

  • Itunes + G15 lover

    Wauw! So much thanx dude! seriously!

    Many,many thanx!

  • Thanks so much! I’ve been trying to work this problem out for ages!

  • Thank you so much for this! I play World of Warcraft and Guild Wars (online video games), and when I’m playing alone I perfer to listen to music. It was annoying, at the least, to need to switch to iTunes to change the song (or pause it when needed). This is exactly what I needed.

Leave a Reply