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.
Binaries
Source Code

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


103 Responses to “ iTunes & Media Keys ”

Comments:

  1. robert says:

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

  2. Sherwin Flight says:

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

  3. James says:

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

  4. Niall says:

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

  5. Adam says:

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

  6. Andrew says:

    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,

    Andy

  7. itunes user says:

    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!!!

  8. gordo says:

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

  9. Michael says:

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

  10. Matt says:

    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.

  11. Pino says:

    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!

  12. egoine says:

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

  13. Skyler says:

    @pino

    I installed with itunes7 already installed, works great

  14. hoju says:

    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 :(

  15. Abu says:

    Thank you very much

    This works with my Compaq Presario M2000

  16. MPLinux says:

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

  17. Bill Dance says:

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

  18. colm lynch says:

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

  19. Chiranth says:

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

    Chiranth

  20. Aaron says:

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

  21. Aaron says:

    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!

  22. Josh says:

    perfect :)

  23. John says:

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

    Cheers.

  24. Geo says:

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

  25. Kevin says:

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

    Thanks

  26. Adam says:

    Great job!

  27. s5brian says:

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

  28. Edd says:

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

  29. J. Vincken says:

    Works great for selecting tracks.

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

  30. Pronk says:

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

  31. Luke says:

    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

  32. J says:

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

  33. Korie says:

    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.

  34. Ely says:

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

  35. andyrut says:

    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.

  36. Alex says:

    It works great, thanks a lot.

  37. Bergtatt says:

    Sweet! Thanks alot!

  38. morbo47 says:

    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.

  39. Ant says:

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

  40. Adam says:

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

  41. Casey says:

    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?

  42. Abhas Kumar says:

    Awesome - it rocks!

  43. Dan says:

    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?

  44. Rob says:

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

  45. Rob says:

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

  46. Michelle says:

    I love you.

  47. Mike says:

    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!

  48. Raul says:

    Hey! Thanks for this. For the record: This works with iTunes 7.3.0.54
    Saludos,

  49. Nathan Hill says:

    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?

  50. Rubin Chen says:

    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!!!

  51. Riph-Raph says:

    Thanks a million Andy! Works like a charm.

  52. Jessica says:

    thank you so very much!!!

  53. Tony says:

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

  54. Alex P. says:

    Thanks a lot. Good work.

  55. Jon says:

    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 7.3.1.3 and Vista home premium for those who keep track.

  56. aaron says:

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

  57. James Joyce says:

    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 7.3.2.6.

  58. Ruth Arnold says:

    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 :)

  59. Paul Jamaal says:

    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?

  60. Anon Y Mouse says:

    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.

  61. Bryan says:

    Thanks :)

  62. Alcon says:

    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.

  63. Matth says:

    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?

  64. Nathan says:

    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.

  65. Bwana says:

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

  66. Melissa says:

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

  67. Mark says:

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

  68. James says:

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

  69. Peter Smith says:

    Excellent. Thank you.

  70. Josh says:

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

  71. Slayer Nine says:

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

  72. Joel says:

    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.

  73. shere says:

    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

  74. duffy says:

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

  75. roberto flores says:

    incredible just what I was looking for

  76. Geoffers says:

    Bravisimo!!!

  77. Kaldir says:

    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. :D

  78. demon says:

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

  79. Mike Warren says:

    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

  80. DreamsOfSteel says:

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

  81. Frankie says:

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

  82. Dan says:

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

  83. Bobby says:

    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.

  84. Nathan says:

    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.

  85. Andrew says:

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

  86. Rob says:

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

  87. Kevin says:

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

  88. Steven says:

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

  89. RH says:

    Thanks!

    Great stuff!

  90. Sunne says:

    Oh My Gosh you are a SAVIOR!!! I LOVE YOU! Thanks sooo much! :-D

  91. Rich says:

    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=0×11ac (4524).
    ———-

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

  92. Dan says:

    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.

    Thanks

  93. Stacey says:

    THANK YOU.

    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!

  94. Ronny Who Dat says:

    Thanks

  95. westone says:

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

  96. damo says:

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

  97. JayJayT says:

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

  98. Itunes + G15 lover says:

    Wauw! So much thanx dude! seriously!

    Many,many thanx!

  99. geneva says:

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

  100. Valerie says:

    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.

  101. Jethro says:

    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.

  102. Dan says:

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

  103. Ryder Ross says:

    This is amazing thank you!


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>