Re: "tell application" without starting application?
Re: "tell application" without starting application?
- Subject: Re: "tell application" without starting application?
- From: Rob Jorgensen <email@hidden>
- Date: Wed, 27 Nov 2002 21:08:42 -0500
At 5:39 PM -0800 11/27/02, Paul Berkowitz wrote:
Not quite. 'name of every process' only mans anything inside a Finder tell
block, but you wouldn't want to put that whole if/else block inside a Finder
tell block since it contains a tell block to another application (or would
if you had remembered to include an 'end tell' line). It's not a good idea
to call one app through another - it slows things down and can occasionally
lead to namespace confusion.)So:
tell app "Finder" to set allProcs to name of every process
if allProcs contains {"iTunes"} then
tell app "iTunes"
-- doThis()
end
else
display dialog "iTunes is not running"
end if
---------------
[Note that the 'contains' operator requires the operands on both sides to be
of the same class. Since 'allProcs', or 'name of every process' is a list,
you should makes a single-item list of the list item you're looking for. In
the case of a string within a list of strings, AppleScript will do the
coercion for you, but in other cases it won't. It's better to do it right
every time so you don't forget when it does matter - say with an application
object such as 'process' in a list of processes rather than strings.]
Here's a more direct method that doesn't require 'contains'.
tell application "Finder" to set itStatus to exists process "iTunes"
if itStatus is true then
tell application "iTunes"
-- doThis()
end tell
else
display dialog "iTunes is not running"
end if
--
Rob Jorgensen
Ohio, USA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.