Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Modified with fader and check to see if itunes is playing' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Modified with fader and check to see if itunes is playing
Authored by: storrence on Apr 23, '04 07:15:49PM

using terms from application "Mail"
-- This is what allows this AppleScript to run as a Rule
on run
--Performs the following action on each new mail received
tell application "Mail" to set sel to selection
tell me to perform mail action with messages (sel)
end run
end using terms from

using terms from application "Mail"
on perform mail action with messages selectedMsgs
-- See Mail's AppleScript dictionary for the full documentation on the
-- 'perform mail action with messages' handler.

tell application "iTunes"
if player state is playing then
set sndbeg to sound volume
repeat
set snd to sound volume
if snd is less than or equal to 20 then
exit repeat
end if
set sound volume to (snd - 5)
delay 0
end repeat
end if
end tell

say "You have mail from"
set logString to "" & return
tell application "Mail"
set selCount to (count of selectedMsgs)
--A little bit of error handling
if selCount is equal to 0 then
set logString to logString & "There are no selected messages."
else if selCount is equal to 1 then
set logString to logString & "There is " & selCount ¬
& " selected message."
else if selCount > 1 then
set logString to logString & "There are " & selCount ¬
& " selected messages."
end if
repeat with counter from 1 to selCount
set msg to item counter of selectedMsgs
set theSubject to subject of msg
set theSender to sender of msg
set theSender to extract name from theSender
set logString to (logString & tab & "Message " & counter as string) ¬
& " from: " & theSender & ", subject: " & theSubject & ". "
if length of logString > 0 then
--note that you could have it speak the subject as well
say ":" & theSender
end if
end repeat
end tell

tell application "iTunes"
if player state is playing then
repeat
set snd to sound volume
if snd is greater than or equal to sndbeg then
exit repeat
end if
set sound volume to (snd + 10)
delay 0.1
end repeat
end if
end tell

end perform mail action with messages
end using terms from

---
Steve



[ Reply to This | # ]
Modified with fader and check to see if itunes is playing
Authored by: abacsalmasi on Apr 23, '04 07:38:13PM

Keep getting syntax error

"Expected end of line, etc. but found identifier"

and it highlights the word - mail - in the text I've included.


" tell me to perform mail action with messages (sel) "

Any ideas?

---
My eyes, my eyes, these goggles do nothing!



[ Reply to This | # ]
Modified with fader and check to see if itunes is playing
Authored by: PancakeMan on Apr 28, '04 11:59:49AM

I get the same error. Is this a Panther-only script? (I'm on Jaguar).



[ Reply to This | # ]
Modified with fader and check to see if itunes is playing
Authored by: tbolt502 on Apr 23, '04 08:41:49PM

OK, so many of us probably live with Itunes on constantly. However, in the rare case that iTunes is not running, all of the scripts here would start iTunes.

Probably not sensible.

Using modified code from plenty of other postings here at MacOSXHints.com to check if an application is running means we can avoid starting iTuines if it is not running. Surround each of the two blocks which control the iTunes Volume with the following:

tell application "System Events"
	if (get name of processes contains "iTunes") then
-- THE iTunes VOLUME CONTROL ROUTINES GO HERE!

	end if
end tell
Just a wee note.

[ Reply to This | # ]
Modified with fader and check to see if itunes is playing
Authored by: Chris Biagini on Apr 25, '04 04:27:49PM

Beautiful! Fine work, gentlemen!



[ Reply to This | # ]