- Code: Select all
----By Ian Dopps 2006
----This script will allow you to email your computer and control itunes. It works great when integrated with Indigo. To use, type the word "itunes" in the subject box. Now, you need to type in the body of the message. In the body, ONLY type the name of the artist on line 1 and ONLY the track number on line 2. If you do not type the track number in, it will start at the first track of the artist. If you want to hear a playlist instead of a specific artist, type "playlist" on line 1 and then the name of the playlist on line 2. This script also supports AirTunes playing. If you want to toggle AirTunes on or off, type "remote" on line 3. Unfortunatly, Itunes has poor GUI and networking script capabilities at this time. Therefore, if you decide to use the AirTunes feature, you need to download the script addition called "Extra Suites". It can be found at http://www.macupdate.com/info.php/id/9730
---Have fun! QUESTIONS? doctorlambo@gmail.com
--------------
tell application "Mail"
activate
delay 1
check for new mail
tell (first message of inbox whose subject is "itunes") to if exists then
try
set target_track to first paragraph of (get content)
on error
set target_track to "playlist"
end try
if target_track is "playlist" then
try
set track_number to second paragraph of (get content) as text
on error
set track_number to "library"
end try
else
try
set track_number to second paragraph of (get content) as number
on error
set track_number to "1"
end try
end if
try
set remote_computer to third paragraph of (get content)
on error
set remote_computer to 0
end try
if track_number is 0 then
set track_number to 1
end if
tell application "Mail"
delete (first message of inbox whose subject contains "itunes")
end tell
---------------------------------
if remote_computer is "remote" then
---REMOTE SPEAKER TOGGLE
tell application "iTunes"
activate
delay 2
set visible of window "remote speakers" to true
delay 1
set {X, y} to position of window "remote speakers"
tell application "Extra Suites"
ES move mouse {X + 15, y + 57}
ES click mouse
end tell
delay 1
close window "remote speakers"
end tell
end if
---------------------------------
if target_track is "playlist" then
tell application "iTunes"
activate
delay 2
tell (playlist track_number) to if exists then
tell application "iTunes" to play (playlist track_number)
else
tell application "iTunes" to play (playlist "library")
end if
end tell
else
tell application "iTunes"
activate
delay 2
set X to number of (tracks of library playlist 1 whose enabled is true and artist is target_track)
if X is less than track_number then
set track_number to 1
end if
tell (track track_number of library playlist 1 whose enabled is true and artist is target_track) to if exists then
tell application "iTunes" to play (track track_number of library playlist 1 whose enabled is true and artist is target_track)
else
tell application "iTunes" to play (playlist "library")
end if
end tell
end if
----------
end if
end tell