MACSCRPT Archives

July 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Lively <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 12 Jul 2006 13:16:12 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (26 lines)
On Jul 12, 2006, at 1:00 PM, Peter Boardman wrote:

> print `osascript -e 'tell application "System Events"
> if (exists process "iTunes") then tell application "iTunes" to if  
> player state is playing then get name of current track
> end tell'`
>
> Why should this be? And is there a way of doing it?
>
It is because when OSAScript compiles the script it needs to launch  
iTunes.

try this

echo `osascript -e 'tell application "System Events"
if (exists process "iTunes") then run script "tell application  
\"iTunes\" to if player state is playing then get name of current track"
end tell'`

Probably a bit slower but it won't launch itunes.  It gets around the  
launching at compile time by making osaCompile view the iTunes  
portion of the script as a string and then having the main script  
compile and run it only if needed.

-Mark

ATOM RSS1 RSS2