How-To: Create an iTunes Remote

Ken Grey turned us on to Quick Macros as an economical X-keys Pro alternative. QM is a supercharged, yet lightweight automation environment which supports multiple input devices. It provides the ability to create custom toolbars, automate repetitive or complex tasks, and cheat at online poker. There's a bit of a learning curve, but numerous canned functions and the ability to record actions help ease you in. QM goes beyond that, though, by offering a COM interface and common scripting support. With that in mind, I created an iTunes remote control using an extra wireless mouse and just a few snippets of code from Apple's SDK.
I. Install Quick Macros
Quick Macros is a quick download and install. The 30 day eval is free, after that it'll cost you $30. For most efficient usage, allow QM to launch at system startup.

- Download and install Quick Macros
II. Prepare Quick Macros For Use With Multiple Input Devices
What makes QM uniquely powerful is the ability to map multiple keyboards and
mice as macro triggers. QM supports Windows 98 and above, though the secondary input feature is limited to XP. Once
the module has been downloaded and imported, set it to launch at QM startup and identify our second mouse.
- Download Keyboard detector.qml
- Open Quick Macros
- Click File > Import
- Browse to and open Keyboard detector.qml
- Click Import button
- Expand Keyboard detector folder in left pane
- Highlight Keyboard_Detector (the one with the blue icon)
- Click the play icon button on toolbar twice

- Check Use Multiple Mouses (mice? meeces?)
- Double-click FF_Mouse2 with your second mouse
- Click Close
- Expand User folder in left pane and highlight init2 function
- Type mac "Keyboard_Detector" under existing
text in the right editing pane
III. Create iTunes Remote Functions
Each mouse action will require its own macro or function. I chose to use functions because they can run simultaneously, though macros work just as well for these simple tasks. iTunes VBScript snippets will be triggered by specific actions on the second mouse, which must be filtered for. After creating the five functions, organize them in their own folder for purely aesthetic reasons.
- Click File > New > New Function
- Name function "PlayPause"
- Right click "PlayPause"
then left click Properties

- Click Mouse tab
- Click middle mouse button icon
- Click Filter button

- Click Use
- Choose FF_Mouse2 from the drop down menu
- Click OK
- In
the editing pane on the right, type:
lpstr vbs=
Set iTunesApp = CreateObject("iTunes.Application")
iTunesApp.PlayPause
VbsExec vbs
(Note the extra space to start lines 2 and 3) - Repeat steps 1 - 10, specifying the appropriate mouse button and inserting the relevant code listed below:
|
Function
|
QM-formatted VBScript
|
|
Volume
Up
|
lpstr vbs= Set iTunesApp = CreateObject("iTunes.Application") iTunesApp.SoundVolume = iTunesApp.SoundVolume [plus sign] 10 VbsExec vbs |
|
Volume Down
|
lpstr vbs= Set iTunesApp = CreateObject("iTunes.Application") iTunesApp.SoundVolume = iTunesApp.SoundVolume - 10 VbsExec vbs |
|
Previous Track
|
lpstr vbs= |
|
Next Track
|
lpstr vbs= Set iTunesApp = CreateObject("iTunes.Application") iTunesApp.NextTrack VbsExec vbs |
- Click File > New > New Folder
- Name the folder "iTunes Mouse Control"
- Drag each function into the folder
- Click X to minimize Quick Macros to the system tray

IV. Remote Control iTunes
The beauty of Quick Macros and iTunes is they both linger in the background waiting for input, regardless of which application is in the foreground. Pressing the scroll-click button on your new remote will launch iTunes and start playback, but you probably want to specify the tracks. For maximum geek effect, consider investing in some Velcro tabs to attach the mouse as shown below.
1. Launch iTunes
2. Fire up a playlist
3. Minimize iTunes to the system tray
4. Control playback via your secondary
mouse while in any app
Wrap Up

If you're looking for universal keyboard control for Apple's ubiquitous player, iTunesKeys is a fine choice. Obviously there's also countless iTunes/iPod accessories out there, in addition to our own web interface tutorial which provides a means of remote control. But if you've got an extra mouse lying around (preferably wireless, RF if you want couch-based control) this quick hack will give it a new lease on in life. Non-iTunes users may want to check out the Windows Media Player and WinAmp SDKs which may also work with QM, though I haven't tested them. Let us know what other clever hacks you'll be cranking out with Quick Macros, just don't tell KoolAidGuy how you did it.

















Hey guys,...
Its easier for Mac users, but if you're a windows user and want to play a particular podcast as an alarm, I've created a script to do it pretty easily...
http://www.mitchumowen.com/downloads/alarm.js
The instructions are in the file. To edit the preferences, you need to open the file with notepad or other editor.
Enjoy!
iTunesControl (http://itunescontrol.com) is another choice for global hotkeys for iTunes on Windows.
how does this allow you to cheat at online poker?
good idea, but why is this on here, not hackaday?
This looks neat.
Ha! You're just doing this to get a free registration number!
lol
or you could buy a mediaplay mouse that actually has all those buttons ON the mouse. just a wacky suggestion.
Could you please addapt that vB into executables? I want to add shortcuts on my bar that does this :)
krill3: I wrote a post last week that explains how to control iTunes from any Microsoft Office application. The code I used there can be easily ported to a VB executable. Just grab it and compile it.
http://thousandrobots.com/blog/archives/2006/01/how_to_control_1.php
or you could just use globel hotkeys in WinAmp and not bother with the above
If it uses COM ports then couldn't you theoretcally use a bluetooth com port with a smartphone to make a similar remote control?
I use the global hotkeys to control my winamp via quickmacros and the Touch Stream FingerWorks keyboard. Hotkeys do have the drawback of being missfired if another app or macro has that key definition. using the script there won't be that problem.
adm: I dont have a compiler, ;)
Ah man I just did it, it's awesome!
Jack if you can figure out a way to do that... That'd be AWESOME. I'd love to control my iTunes through my phone.
One thing to note: Volume up did not work for me at first, but once I added a "+" everything worked fine... My code looked like this:
lpstr vbs=
Set iTunesApp = CreateObject("iTunes.Application")
iTunesApp.SoundVolume = iTunesApp.SoundVolume + 10
VbsExec vbs
Anyone else have that prob?
I've been looking for something like this for a while. Now if only I had a wireless mouse!
Krill3: For a simple global hotkeys iTunes app, check out iTunesKeys (http://www.mattberube.com/software/ituneskeys/)
Jack: I was referring to a COM programming interface, not the COM ports. Sorry for the confusion. A bluetooth interface sure would be sweet!
Khamel: This hack isn't intended to replace a media mouse or keyboard, it's intended to teach you how to use QuickMacros powered by a secondary input device. I've given you the keys to the kingdom, how you use them is up to you.
on the mac use almost any bluetooth phone with Salling Clicker($$) or Romeo (free)...
"One thing to note: Volume up did not work for me at first, but once I added a "+" everything worked fine...
Anyone else have that prob?"
That's why he put [plus sign] maybe there's something that prevents putting "+" in a blog post. Worked perfectly for me! Even if I am using a wired PS/2 mouse...
I just wrote a hot key handler for iTunes on a Windows system. http://www.jacobhickman.com/hotkeys/ It requires the .NET Framework 2.0 (get it from windowsupdate.com) but it a very straight-forward application. I still consider it beta, but you're welcomed to use it. My contact info is on the page, if you want source code (VB), just email me.