/iTunesControl

[Unmaintained] Global Hotkeys for iTunes

Primary LanguageHTMLMIT LicenseMIT

iTunesControl

Global hotkeys for iTunes on windows.

Disclaimer: Since this has become my most popular repository, I would like to add that is code is absolutely not representative of the type of code I produce now that I — y'know — actually know how to program. For details see below.

What's in here?

  • iTunesControl.py - The original python script, requires pyHook and the python win32 hooks installed. It's probably working.
  • iControl.ahk - Autohotkey re-write of the original script. Mostly just for noodling around with autohotkey.
  • iTunesCOM - The ridiculously hard to find iTunes COM interface documentation. I've put it up on github pages here.

Hotkeys

Basic Keyboard Shortcuts

Alt + Q Qut the application
Alt + P Toggle Play/Pause
Alt + Right Next Track
Alt + Left Previous Track
Alt + Up Volume Up
Alt + Down Volume Down
Alt + (-) Mute (Set volume to 0)
Alt + (+) Max Volume (Set volume to 100)
Alt + S Toggle Shuffle

Advanced Keyboard Shortcuts

Note: the Alt key must be held down durning the entire command.

Alt + R + {1, A, N} Toggle repeat. R+1 is repeat one. R+A is repeat all. R+N is repeat none.
Alt + H + [Playlist Name] + Enter Play playlist [Playlist Name] (Alt key must be held down while entering playlist name
Alt + O + {1, 2, 3} + [Search Term] + Enter Search for term [Search Term] based on {1, 2, 3}, put those songs into a new playlist, and start playing the playlist. 1: Search by artist name. 2: Search by album name. 3: Search by song name. (Again, the Alt key needs to be held down during the entire command)

Mouse Commands

Alt + Click Toggle Play/Pause
Alt + Click and Drag to the Right Next track
Alt + Click and Drag to the Left Previous track
Alt + Scroll Up Volume Up
Alt + Scroll Down Volume Down

Some Tips and Cautions

  • Alt + H + "Music" - Will play the playlist "music" which is the entire library. It's good for switching back once you get bored of a playlist.
  • If for some reason you want to used in a program that has been "run as administrator" this program also needs to be run as administrator.

Design and Hacking (really it's an apology)

I wrote this program back when I was about 15, and really new to both python and programming in general. I think this is the first program I wrote that used threads, and I don't think I quite knew what that meant besides "you can run more than one thing at once" and "you have to pass messages with a queue or it will crash". I've tried to hold off on releasing this because it's in such bad shape, but I haven't had the time or the patience to clean it up myself. Good luck if you try, open a pull request with improvements. Since the thing has about zero comments explaining what it does, I'll add a brief description of the design below.

It works like this: pyHook keylogs every keystroke, and passes it back to the operating system. If a keystroke is entered and the Alt key is depressed at the same time, the program will block the keystroke from reaching the other applications, and put it into a queue. (There a two separate queues, one for the mouse and another for the keyboard). There are two threads that loop waiting for an item to come through the queue, both of the threads maintain a connection to iTunes using it's COM interface. Once an item is received, they have huge conditional sections that execute COM functions based on the key pressed. Things get a little more complicated with the text-entry stuff, basically it just bypasses the other conditionals.

Have fun, and good luck using it (and please believe me when I say I write much better code these days).