Re: Name of Active Process
Re: Name of Active Process
- Subject: Re: Name of Active Process
- From: Joseph Weaks <email@hidden>
- Date: Thu, 17 Jun 2004 10:32:57 -0500
On Jun 17, 2004, at 8:36 AM, Paul Berkowitz wrote:
Well, he did say 'as text' which should have coerced the single-item
list to
the same text without the list braces. (I do wish people would start
getting
used to 'as Unicode text' though: one of these days, 'as string', 'as
text'
is going to land you in trouble.)
Why bother with coercions, though? 'first' is designed for this
situation
(OK, 'some will work too, but...) And why use the Finder (yet another
coercion) when it's System Events that actually does this job and
you're
(David) is calling System Events two lines later anyway?
tell application "System Events" to set frontProcess to name of
first
process whose frontmost is true
My apologies for not cleaning up my examples to the bare minimum. They
included concatenations that I should have removed for clarity; thanks
for seeing past them.
As per standard practice among some, I, too, avoid Finder when I can,
but the problem is that "whose frontmost is true" can fail when run in
some environments:
tell application "System Events" to set frontProcess to name of first
process whose frontmost is true
-- run from the Apple script menu returns:
-- System Events
But, using Finder's "frontmost application" still works:
tell application "Finder" to set frontProcess to (displayed name of
(path to frontmost application))
-- run from the Apple script menu returns:
-- Mail (or whatever)
If your script has control over the environment, then using System
Events is well and good, but it's an issue that helps to be aware of.
Joe Weaks
_______________________________________________
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.