Re: Determining frontmost application in OS X
Re: Determining frontmost application in OS X
- Subject: Re: Determining frontmost application in OS X
- From: Christopher Nebel <email@hidden>
- Date: Thu, 18 Jul 2002 19:32:15 -0700
What I meant by "currently" is that that's what happens today, but there
are no guarantees about tomorrow. System Events just returns the list
in the order that the Process Manager does. As it happens, that's
launch order, but that's not specified anywhere, so they could change it
if they felt like it. In other words, don't rely on it, or if you do,
at least don't whine if your script breaks.
--Chris Nebel
AppleScript Engineering
On Thursday, July 18, 2002, at 04:17 PM, Paul Berkowitz wrote:
Where do you hat, Bryan? Of course "items of" is working! Chris was just
saying that the ordering of the list of processes is ("currently" -?) in
launch order, not UI layer order.
--
Paul Berkowitz
From: bryan <email@hidden>
Reply-To: email@hidden
Date: Thu, 18 Jul 2002 18:23:06 -0400
To: email@hidden
Subject: Re: Determining frontmost application in OS X
So, now "...whose..." is working but "items of..." isn't?
When did that happen? I made the 'mistake' of upgrading from
10.1.2b3 to 10.1.5 and broke my scripts.
I tried going back to 10.1.2b3 with no luck.
Anybody have any ideas?
Bryan Kaufman
Christopher Nebel wrote:
On Thursday, July 18, 2002, at 05:32 AM, email@hidden
wrote:
The question is, how to figure out which application is the frontmost
one. Telling the Finder to get the processes gives me a list, but the
first item in the list is always "loginwindow."
tell application "Finder"
get the name of every process
end tell
(result below)
{"loginwindow", "Finder", "AEServer", "Dock", "SystemUIServer",
"PhotoStickies", "MooSB", "Show Desktop", "Key Xing Listener", "Palm
Desktop Background", "Transport Monitor", "MoonMenuXBackgrounder",
"ASM
Controller", "System Events", "Mail", "SecurityAgent", "Internet
Explorer", "System Preferences", "Script Editor"}
Can I get this list sorted "front to back?"
If you want the last item of the list, you could say "last item of
the_list" or "item -1 of the_list" (negative indicies go from the
end).
The problem is, that won't tell you the frontmost one, because that's
not how the list is ordered. It's actually not specified what order
the
processes are in, but it happens (currently) to be in launch order, so
the last one is the most recently launched.
Fortunately, processes have a "frontmost" property. If you substitute
"get the name of processes whose frontmost is true", you should get a
list of one string, e.g. {"Mail"}.
_______________________________________________
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.