Last week I talked about controlling your Mac with an e-mail; this week, as promised, I am going to show you how to apply this same idea to iTunes. So, without further ado, let's get started with writing some AppleScripts. Continue reading to learn how to control iTunes.
Creating the AppleScripts
For this tutorial, I am going to show you how to control iTunes in the following ways: open, play, stop, skip and play a specific playlist. Just copy whichever script you want to use from the list below and paste them into the Script Editor (Script Editor.app can be found in ~/Applications/AppleScript/ Script Editor).
Open / Play iTunes
tell application "iTunes"
activate
play
end tell
Stop Playing
tell application "iTunes"
stop
end tell
Skip Track
tell application "iTunes"
next track
end tell
Start playing a specific playlist
tell application "iTunes"
set the_playlist to user playlist "typenameofplaylisthere"
set view of front window to the_playlist
play the_playlist
end tell
Additional Information
For the "Start playing a specific playlist" AppleScript, you need to define a playlist in the "typenameofplaylisthere" section -- remember to retain the quotation marks around the name as well as type the playlist name exactly as you see it in iTunes. For instance, if I wanted to use the Party Shuffle playlist, I would type "Party Shuffle" in this line.
Saving Your Scripts
You can now save your Apple Script in the format you want. You can also use this script to change tracks or load a new playlist by e-mail. Just follow the instructions in last weeks post to learn how to do this.
Mac Automation posts are published weekly here on TUAW, be sure to come back next week for more AppleScripty goodness.











Reader Comments (Page 1 of 1)
4-13-2008 @ 9:21PM
Bender Bending Rodriguez said...
Don't get me wrong, I love these AppleScript blogs, but in what instance would this particular script be used. I can't think of any unless you are trying to gaslight a roommate.
Reply
4-13-2008 @ 9:25PM
Cory Bohon said...
You can use this if you don't have an Apple remote or any way to control iTunes other than being directly in front of the computer. This would be great for someone who might have an Airtunes system set up with an Airport Express or AppleTV and want to change the track or playlist.
4-13-2008 @ 9:41PM
Murphy Mac said...
Cory - Are you hanging out in my closet?
http://murphymac.com/select-a-playlist-by-email-and-more/
http://murphymac.com/sleep-your-mac-by-email/
Reply
4-13-2008 @ 10:24PM
Dan said...
You can also control everything on your computer with twitter:
http://www.maciverse.com/control-your-mac-with-twitter.html
Create Automator Tasks, save them as an app, and then launch them with an apple script + mail rule.
Reply
4-14-2008 @ 9:24AM
Steve said...
I can see myself using this if I had a private Shoutcast stream that I wanted to control from another computer.
Reply