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.





















Reader Comments (Page 1 of 1)
jared @ Jan 17th 2006 3:40PM
how does this allow you to cheat at online poker?
Tom @ Jan 17th 2006 3:46PM
good idea, but why is this on here, not hackaday?
Charlie @ Jan 17th 2006 3:54PM
This looks neat.
Arsey @ Jan 17th 2006 4:00PM
Ha! You're just doing this to get a free registration number!
lol
khamel @ Jan 17th 2006 5:24PM
or you could buy a mediaplay mouse that actually has all those buttons ON the mouse. just a wacky suggestion.
KriLL3 @ Jan 17th 2006 5:32PM
Could you please addapt that vB into executables? I want to add shortcuts on my bar that does this :)
adm @ Jan 17th 2006 6:02PM
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
rob_ @ Jan 17th 2006 7:36PM
or you could just use globel hotkeys in WinAmp and not bother with the above
Jack @ Jan 17th 2006 8:19PM
If it uses COM ports then couldn't you theoretcally use a bluetooth com port with a smartphone to make a similar remote control?
ken gray @ Jan 17th 2006 8:22PM
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.
KriLL3 @ Jan 17th 2006 8:35PM
adm: I dont have a compiler, ;)
Ari @ Jan 17th 2006 11:52PM
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?
Sam @ Jan 18th 2006 1:55AM
I've been looking for something like this for a while. Now if only I had a wireless mouse!
Dave Zatz @ Jan 18th 2006 9:50AM
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.
Jon @ Jan 18th 2006 5:27PM
on the mac use almost any bluetooth phone with Salling Clicker($$) or Romeo (free)...
Dan @ Jan 19th 2006 7:39AM
"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...
Jacob @ Jan 29th 2006 1:52PM
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.
Mitchum @ Aug 24th 2006 12:39PM
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!
Carson @ Sep 17th 2006 12:09PM
iTunesControl (http://itunescontrol.com) is another choice for global hotkeys for iTunes on Windows.