• 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
Listing Applications by Index Order - was Frontmost Application...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Listing Applications by Index Order - was Frontmost Application...


  • Subject: Listing Applications by Index Order - was Frontmost Application...
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 24 Apr 2019 20:53:32 -0500

Hey Jean-Christophe,

Yvan has given you a working solution for this, but there is a way to list apps
by index order.

The caveat is that they MUST be visible – hence the System Events code.

I've massaged the output of `lsappinfo` a trifle, but I've left in the serial
number – so you can see what they look like.


--
Take Care,
Chris

------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2019/04/24 20:29
# dMod: 2019/04/24 20:29
# Appl: Miscellaneous, System Events, Shell
# Task: List Applications by Index order (front-to-back).
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @List, @Applications, @Index,
@Order, @Front_to_Back
------------------------------------------------------------

tell application "System Events"
    set invisibleProcesses to processes whose background only is false and
visible is false

    # Apps MUST be VISIBLE to be seen by `lsappinfo`.
    repeat with i in invisibleProcesses
        set visible of i to true
    end repeat

end tell

set shCMD to "
lsappinfo visibleProcessList \\
| awk -v OFS=\"\\n\" '{$1=$1}1'"
do shell script shCMD

------------------------------------------------------------

To ditch the serial numbers and underscores change the shell command to:

set shCMD to "
lsappinfo visibleProcessList \\
| awk -v OFS=\"\\n\" '{$1=$1}1' \\
| sed -E '-e s!^.*\"([^\"]+)\".*$!\\1!' -e 's!_! !'
"

------------------------------------------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Listing Applications by Index Order - was Frontmost Application...
      • From: Jean-Christophe Helary <email@hidden>
  • Prev by Date: Re: Keychain on Mojave
  • Next by Date: Re: Listing Applications by Index Order - was Frontmost Application...
  • Previous by thread: Re: Email client
  • Next by thread: Re: Listing Applications by Index Order - was Frontmost Application...
  • Index(es):
    • Date
    • Thread