Joystiq has your stash of criminally complete GTA IV news!

AppleScript: Control iTunes with an e-mail

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.

Related Headlines

Reader Comments (Page 1 of 1)

Add your comments

Please keep your comments relevant to this blog entry. Email addresses are never displayed, but they are required to confirm your comments.

When you enter your name and email address, you'll be sent a link to confirm your comment, and a password. To leave another comment, just use that password.

To create a live link, simply type the URL (including http://) or email address and we will make it a live link for you. You can put up to 3 URLs in your comments. Line breaks and paragraphs are automatically converted — no need to use <p> or <br> tags.

New Users

Current Users

TUAW Features

Mac 101 iPhone Around the Worldask-tuaw
Mac News
Macworld (497)
.Mac (38)
Accessories (624)
Airport (75)
Analysis / Opinion (1291)
Apple (1609)
Apple Corporate (547)
Apple Financial (186)
Apple History (38)
Apple Professional (49)
Apple TV (160)
Audio (441)
Bad Apple (119)
Beta Beat (148)
Blogging (87)
Bluetooth (15)
Bugs/Recalls (56)
Cult of Mac (869)
Deals (200)
Desktops (114)
Developer (205)
Education (93)
eMac (10)
Enterprise (126)
Features (373)
Freeware (363)
Gaming (344)
Graphic Design (18)
Hardware (1269)
Holidays (41)
Humor (587)
iBook (65)
iLife (237)
iMac (183)
Internet (306)
Internet Tools (1289)
iPhone (1350)
iPod Family (2020)
iTS (962)
iTunes (794)
iWork (18)
Leopard (355)
Mac mini (109)
Mac Pro (50)
MacBook (196)
MacBook Air (77)
Macbook Pro (214)
Multimedia (433)
Odds and ends (1417)
Open Source (271)
OS (890)
Peripherals (190)
Podcasting (181)
Podcasts (83)
Portables (196)
PowerBook (137)
PowerMac G5 (50)
Retail (572)
Retro Mac (47)
Rig of the Week (42)
Rumors (612)
Software (4220)
Software Update (395)
Steve Jobs (252)
Stocking Stuffers (55)
Surveys and Polls (96)
Switchers (111)
The Woz (34)
TUAW Business (227)
Universal Binary (281)
UNIX / BSD (62)
Video (909)
Weekend Review (74)
WIN Business (49)
Wireless (80)
XServe (35)
Mac Events
One More Thing (27)
Liveblog (0)
Other Events (231)
WWDC (181)
Mac Learning
Ask TUAW (96)
Blogs (85)
Books (23)
Books and Blogs (63)
Cool tools (444)
Hacks (462)
How-tos (480)
Interviews (33)
Mods (184)
Productivity (583)
Reviews (99)
Security (145)
Terminal Tips (56)
Tips and tricks (559)
Troubleshooting (161)
TUAW Features
iPhone 101 (23)
TUAW Labs (3)
Blast From the Past (17)
TUAW Tips (141)
Flickr Find (32)
Found Footage (70)
Mac 101 (81)
TUAW Interview (30)
Widget Watch (196)
The Daily Best (2)
TUAW Faceoff (5)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Sponsored Links

The Unofficial Apple Weblog (TUAW) bloggers (30 days)

#BloggerPostsCmts
1Dave Caolo490
2Cory Bohon455
3Mat Lu374
4Erica Sadun351
5Scott McNulty341
6Michael Rose2919
7Brett Terpstra240
8Mike Schramm194
9Robert Palmer1322
10Steven Sande139
11Joshua Ellis64
12Christina Warren618
13Nik Fletcher41
14Chris Ullrich21
15Victor Agreda, Jr.14
16Jason Clarke11
17Lisa Hoover11

Featured Galleries

Macworld 2008 Keynote
Macworld 2008 Build-up
Macworld Expo 2007 show floor
The Macworld Faithful in Line
iPhone First Look
iPhone 2.0 - .Mac push e-mail
iMac 1998
TUAW Faceoff: Screenshot apps on the firing line
Boston Apple Store (Boylston Street)

 

    Most Commented On (7 days)

    Recent Comments

    More Apple Analysis

    More from AOL Money and Finance

    Weblogs, Inc. Network

    Other Weblogs Inc. Network blogs you might be interested in: