Latest in Applescript

Image credit:

AppleScript: Control iTunes with an e-mail

Cory Bohon

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 can be found in ~/Applications/AppleScript/ Script Editor).

Open / Play iTunes
tell application "iTunes"
end tell

Stop Playing
tell application "iTunes"
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.

From around the web

ear iconeye icontext filevr