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”

  • thank you so much for this. it’s exactly what i was looking for.

  • Thanks for making this. It was very annoying to have to manually click the buttons in itunes to do this.

  • Thanks for taking the time to make this available. So simple and so useful!

  • Thanks so much for creating this. This was the one reason why I refused to use ITunes beffore. Works great so far.

  • Thank you so much for making this. it works great on my E1505!!!

  • Thank you for this gem.

    i have not found anyone else doing this – very bizarre. As for Apple…well what are they up to?

    software works great, perhaps a little hungry on resources 15,436K puts it in 7th place on my resouce hit list. however its definatly worth it!!

    – Especially with my X-FI remote i can now control itunes more conveniently than ever!

    Thanks again Andy,


  • Thank you… Just note that the ituneskeys needs to be run from the directory that you copied the files to. Can’t use path.

    Works perfectly!!!

  • thanks it works great!
    but i just updated iTunes now it wont work properly

  • Great!
    Thanks for solving that problem, and sharing it with the rest of us!

  • I use a program called HoeKey Takes up 168k its the second lowest on my memory list. Right now i use windows key->z to play. This program is fully customizable if you know the key codes. But i cannot find the media key codes to make it work.

  • Thanks Andy 🙂

    For some reason, I never had this problem before I got iTunes 7 and I’m hoping it will be solved in future updates. Until then, thanks for the good work!

  • Thank you! Works great on E1405 (640m).

  • @pino

    I installed with itunes7 already installed, works great

  • when i run ituneskeys.exe the red x error msg pops up “this prgm faield to initialize pls click to terminate prgm” i not sure if i puttin stuff in right directory…help pleease 🙁

  • Thank you very much

    This works with my Compaq Presario M2000

  • Amazing!!! 100% working on my Inspiron 6400!

  • Damn, this is exactly what I was looking for for a really long time. Props to you!

  • hey, thanks for this handy tool!
    Works a treat.
    Although you think they would have this built into iTunes.

  • Thanks a lot for this tool! Works like a charm.
    I’m using it on Dell Inspiron 6000 with Win XP Professional.


  • Hey, it works great. I’ve got a Dell Inspiron E1705. Thanks so much!

  • Wow…20mb of ram usage…I guess that’s why I paid for 2gb…lol :-p
    Works perfect though, makes my g15 media keys work on itunes when it’s in the background. Thanks!

  • Wow. Thanks for this. This has been a thorn in my side for a year now. Works great!


  • Sweet! Works an absolute treat. Why I needed to search google to fix this is beyond me. Come on Apple, pull your finger out!

  • You have no clue how much I’ve been waiting for this.


  • Dude, you rock. The program works great in Vista Business.

  • Dude you rock thank you so very much!!!
    You are a f#@$n genius!!

  • Works great for selecting tracks.

    On my Inspiron 9300 though the play/pause button does not work.

  • Thank you very much.. Exactly what I was looking for

  • I’ve put the 3 extracted files from the Binaries zip into the same folder, and I’m getting app error messages when I go to run the .exe files.

    Do these not work with iTunes 7.1? or am I doing something wrong.

    Please help! thanks

  • Luke, iTunes 7.1 should support media key use even when not the window is not active.

  • it works for one try and then it doesnt and sometimes the error message pops up i have 7.1 i dk if im oding it right.

  • Hey, it doesn’t seem to work my Acer Aspire. That’s a pity but nice shot anyway!

  • Thanks! This is awesome!

    However, I’m on an Inspiron E1405 and the Play/Pause button doesn’t seem to work. When I hit the button, it pauses and starts right away without hitting anything else.

    This is an excellent tool, thanks again.

  • It works great, thanks a lot.

  • Sweet! Thanks alot!

  • Wow, thanks! I was so pissed off when those keys suddenly stopped working, and going back to iTunes 6 suddenly meant my library was unreadable… grr…

    You`re a lifesaver! Well, probably not, but it`s still made my day.

  • A fantastic little piece of kit, thanks for the time you put into it!

  • I just upgraded to iTunes 7.2 and experienced this annoying problem. This program fixed it perfectly, thanks a lot!

  • Thanks this app works perfect.

    Would it make sense to be able to install this app as a service? Anyone know how to do that?

  • Awesome – it rocks!

  • When I try to run ituneskeys.exe an application error pops up with “The application failed to initialize properly (0xc0000135).” Can anyone help me out?

  • Well done, I was about to write a similar proggy before I found your post…

  • My ituneskeys has just stopped working, anyone else have any issues?

  • I love you.

  • Not being able to control iTunes from my inspiron’s media buttons has bugged me for a long time. This app just worked (iTunes 7, XP Pro, Inspiron XPS). Many, many thanks. Let’s hear it for people solving problems!

  • Hey! Thanks for this. For the record: This works with iTunes

  • OK, so I’m not crazy. I thought the media keys worked even without the itunes window being active back in the v6 days. I just don’t understand why apple takes features away with each new release. Are they trying to add up little annoyances to get us to all buy Macs? lol

    Anyone have a good way of starting itunes and ituneskeys together? Some sort of script… or something?

  • You are Godlike. I love you. lol, I’ve been looking for something like these for what seems like forever. OMG, I can’t believe that is that simple and yet complicated. LOL. Thank You so much!!!

Leave a Reply