Re: Name of Active Process
Re: Name of Active Process
- Subject: Re: Name of Active Process
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 17 Jun 2004 09:56:01 -0700
On 6/17/04 8:32 AM, "Joseph Weaks" <email@hidden> wrote:
>
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.
Ah, that's interesting. But that's NOT the Finder's 'frontmost application'
- the only thing you're using the Finder for is 'displayed name' , as
someone said already. You're using 'path to frontmost application' - a
scripting addition. (That used to be the same as 'path to current
application', but now there's a distinction: very good indeed.) System
Events also has 'displayed name' - I'm not sure if it's working - I'll check
in a moment. And 'path to [first/every/some] process whose frontmost is
true' will be the same in System Events and Finder, since it's actually
System Events doing it.
So the difference you're claiming for the Finder is not correct - it's the
difference between using 'path to frontmost application' - which seems to
ignore the real application running the script and instead give the one we
actually want - and the System Events and Finder's frontmost property of
process.
It works just as well using 'displayed name' in System Events as in Finder:
try it in the Script menu:
set frontProcess to (path to frontmost application)
tell application "System Events" to set frontProcess to (displayed name
of frontProcess)
display dialog frontProcess
--
Paul Berkowitz
_______________________________________________
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.