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.

    Got it working in about 10 secconds (unusual for me :P) and it’s really usefull. Something you wouldn’t be able to go without after trying it.

    Thanks again, great work.

  • Seems to work for my rocketfish bluetooth mouse and keyboard too. Thanks.

  • This is amazing thank you!

  • Thank GOD for you and this discovery! It works great on my Toshiba Satellite P305D-S8818 running Vista Home Premium and iTunes

    I was SO disappointed to learn that Toshiba’s utility couldn’t do this with anything other than WMP.


    ps – Don’t know if it was mentioned, but I stuck a shortcut to iTunesKeys.exe in my startup directory.

  • Great! Thanks a bunch! I was playing a computer game, and couldn’t really reach Ctrl+Alt+S to change song.

  • Thank you so much! This worked like a charm, on my Dell XPS with Vista Home Premium and iTunes

  • Wow…I applaud your efforts here. I recluctantly downloaded iT today…havent had an iPod for 4 years now since Android phones, but I am so used to the interface. I dreamt of using my buttons on my HP DV7 laptop and I found this site. Thanks for the work and I got it to work in literally 2 minutes.

  • wow, you’re a genius! ive been trying to figure this out all day. thanks so much 🙂 worked IMMEDIATELY.

  • This works perfectly! THNX!

  • HEY!!!! Awesome programming!!! XD Worked! Love it!

  • Thanks for creating these! I didn’t really expect to find a solution when I googled this problem, but it works well. Now I don’t have to use windows media player anymore.

  • Thanks a lot for this!

  • Thanks so much for the program, does exactly what I wanted it to do, only problem I have found is that you are able to load 2 instances of the program at once, which means that hitting the play/pause button will cause a slight pause then replay. Another recommendation would be to have an option to boot on start-up, thanks for the great program.

  • This is working perfectly. Thanks so much for taking the time out to get this done.

  • Great!

    Is this still being developed, or has it been discontinued? Because it still works!

  • @Max, I haven’t touched it in many years, but I’m thrilled that so many people still get value out of it.


  • Brilliant – and I bet a bit surprising you’re still getting notes about that, but for those who need it, this is excellent!

  • thanks a lot! it works like a charm with great work

  • Only issue I’m having is in fullscreen apps it doesn’t let me control still =/

  • it doesnt works with itunes 10.5 🙁

  • Just tried with the new 10.5 update and it works perfectly. Thank you!

  • Is there a way to change the keys that the program looks for? I just got a microsoft keyboard (comfort curve 2000), which has no previous and next track button, but only back and forward buttons. I previously had a microsoft natural multimedia keyboard which did. This worked fine with ituneskeys when Itunes was minimized. However, the new keyboard previous/next track does not work, even when they are mapped to the previous/next track via Intellitype. Is there a way to revise ituneskeys so that it checks for the back/forward buttons?

  • It don’t work, I have no itunes display on screen and no key work.

    Win 7 64
    last version of itunes and logitech control panel

  • ok I have activate the “Human Interface Device Access” and it work now to control itunes with keys.
    But it don’t display itunes on screen 🙁

  • Since I updated to iTunes 10.5 iTunesKeys does not work correctly any longer. It still works fine if iTunes is the active window, but if it is not, then it sends the commands twice. Duh, hang on… Yep. iTunes now recognizes my keyboard media keys by itself. If I exit iTunesKeys, all works as it should. Fail. Yet… WIN ! 🙂 Thanks for the years of saving me from Apple’s tardiness.

  • FANTASTIC! Thank you so much for doing this, works absolutely fine.

  • Thanks for making this tool, it’s been driving me crazy not being able to control itunes when in the background.

    If it’s not too much trouble, could you please make a version without the tray icon? Or at least a way to disable it.

    Thanks in advance for any help you can offer.

  • I have the reverse problem. I want the dedicated media keys to control WMP, but instead ITunes catches them whenever it is open. (Windows 7, iTunes 10.5)

    Any ideas how i can *stop* iTunes from listening to the media keys?

    – Shai

  • Running (Trying not to upgrade for fear of this not working anymore) Crashed everytime I pressed a media button. In an earlier “fix” for this, someone said run iTunes as administrator. I turned that back off and ItunesCommandPasser doesn’t crash anymore. Works great!

  • Doesnt work, got windows 7 64 bit and started it it opened nicely minimized in my status bar but when I hit one of the media buttons on my microsoft 3000 keyboard ItunesCommandPasser crashes, but thanks for the effort.

  • Hi there.
    I was mislead into thinking your utility allowed users to set up shortcuts to control iTunes while in the background. My computer unfortunately doesn’t feature media control keys, do you know of any way to bypass them? I have been looking around but every solution I seem to find turns out to not work with iTunes/my computer etc. (such as godmode..)

  • Thanks for sharing! Scanning through the comments, it pains me to see all the posts by people who can’t just be grateful that you shared with everyone something you just happened to make for yourself (or can’t be bothered to read your post and don’t realize your programs don’t apply to their situation.) This has annoyed me about my Inspirion pretty much since day 1; so glad I stumbled across your page!

  • Worked without any problems! Thanks!

  • Brilliant. Bought a blackwidow ultimate from razer, and they’ve decided that even in old versions of their keyboards, the media keys work fine for itunes, but for all the new stuff they removed support. Tried mmKeys, HKtunes, then this. This was the only one that worked.

    +1 internets to you, good sir

  • Same as Ben. I’ve been looking for something like this for hours.

  • I’ve been using this utility for about 6 months now on my Microsoft X4 keyboard. I’m not sure what happened but for some reason the “next” button no longer works (I believe the most recent iTunes update may have something to do with it). The pause/play and Previous buttons still work however. Any idea what may have caused this and/or how to fix it?

  • Thank you kind Sir.
    I was getting pretty frustrated trying to get my Media keys to work, and stumbled across your fine work.

  • Amazing fix. Worked great on the first try, thank you!!

  • Hey, just wanted to say this still works in 2014! 8 years after your launch and it still works like a charm! Thanks!!

  • Just a note of thanks; came over from OS X to Windows 8.1, and this tool works on my media keyboard on iTunes 12. Yay!

  • Su como usted leer mi mente pensamientos! Usted pareces
    captar mucho aproximadamente esto, como usted e -book en ella o algo así.
    Creo que pude puede hacer con un poco de % a vigor un poco, pero distinta en lugar de eso, esto es es gran blog.

    Una gran ver . Voy definitivamente duda volveremos.

  • Had the same problems after upgrading to Windows 10. Re installed ituneskeys but now it seems to crap out saying ‘itunescommandpasser.exe is not working’
    I found if you set it to start in compatability mode and to start as an Administrator it still works.

  • hey! any chance you could allow for customization of the media keys? I used microsoft keyboard centre to remap the search and email buttons to back and forward respectively as my keyboard doesn’t have next and back keys. I’d like to be able to be like “yeah dis here is the “next” key kek” but thank god you released this software. just updated to windows 10 and already there’s bs going on. thanks for the solution.

  • This works great! Thanks for sharing. My new Razer keyboard has media keys but they didn’t work while iTunes was minimized.

  • Thank you. My 10 years old g15 feels complete again 🙂

  • Thank you from 2018! Wish I had a understanding of the programming stuff and app dev for the win OS. It’s so cool and useful!

Leave a Reply