Control iTunes using keyboard media keys

Just a quick post: I have had a really bad programming itch ever since I got my new Dell laptop recently. It has a row of media keys to go back, forward, play/pause and stop my music. Unfortunately, these keys only work when iTunes has the focus, which kind of sucks. I decided, finally, to do something about it, and wrote a small program that lets you control iTunes using these media keys, even when it doesn’t have focus. The program lives in your system tray, and you can exit it by right-clicking on it.

There are a number of issues with it, and things I could improve, including:

  • It only works on Windows.
  • It requires Java 6.
  • It only works on x86 computers, although if anyone wants, I can make it work on x64 with a little testing.
  • It allows for multiple instances to be run, meaning that if you have two instances running, clicking back on your keyboard will take you back two songs.
  • It doesn’t give any song notification, etc – it is just a controller. If people really want song notification, let me know.

As you should note, the amount of code written is actually minimal: this project is mostly just tying together two other libraries, and of course the iTunes COM interface.

There is a zip file here that contains everything – libs, source code, and a batch file that you can use to start the program. Normal lazy programmers license applies: if your computer crashes and burns, send me photos, but please no complaints. If you use it and (dis)like it, let me know!

Cheers,
Jonathan Giles

21 thoughts on “Control iTunes using keyboard media keys”

    1. Thanks for that. I was sure a solution was out there, but I never knew what to search for, and so it seemed easier to develop my own. If you look at the code it is minimal, so it wasn’t a major project. I’ll look into that link and will probably replace my app with this one 🙂

  1. I just came across your website and downloaded your program, I then tried to install it but it would not. I do have windows vista. It gave me a message that says “Could not find the main class: MediaKeyITunesController. Program will exit.

    Thanks,
    Nate

    1. Nathan,

      I would recommend you look into alternate programs. I no longer use or endorse the use of this software, as better solutions exist. Unfortunately, I can’t offer a recommendation as I don’t know what the plugin I’m using is called. Regardless, it’s a DLL for iTunes, and works very well.

      I’m sure Google may help.
      Cheers, and good luck 🙂
      Jonathan

  2. Hi – just wanted to let you know that I tried both this and the iTunes plugin someone mentioned, and that one didn’t work with my Pause/Play button (the most important one!) – but yours did! Thanks!

  3. I have the same issue with SMPlayer, the controls only work when the window is focused. How hard would it be to adapt this code to that?

  4. Hey just wanted to say thanks for this program, since the dll version doesn’t work when you’re running a full screen program. Great work!

  5. Excellent little batch file. Works exactly as iTunes SHOULD work with Media keys. As of this posting works flawlessly with iTunes 9 on Windows 7 32 bit. Brilliant.

  6. Hey there, I’ve tried clicking the .bat file, but I receive an error “Windows cannot find ‘javaw’. Make sure you typed the name correctly, then try again.”

    Is there a way around this?

    1. You probably have an x64 or 64-bit based system, just like me. I would love a x64 version of this program!

      Thank you in advance!

  7. Works perfectly, but when iTunes is minimized in the task bar, it doesn’t work D: Maybe something you could perhaps fix?? 🙂

Leave a Reply