• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Determining frontmost application in OS X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 10:55:25 -0700

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"}.


--Chris Nebel
AppleScript Engineering
_______________________________________________
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.

  • Follow-Ups:
    • Re: Determining frontmost application in OS X
      • From: bryan <email@hidden>
References: 
 >Determining frontmost application in OS X (From: email@hidden)

  • Prev by Date: RE: Go To Commands (AppleScript)
  • Next by Date: Re: GoTos?
  • Previous by thread: Re: Determining frontmost application in OS X
  • Next by thread: Re: Determining frontmost application in OS X
  • Index(es):
    • Date
    • Thread