The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

List The Foreground Apps Running On A Mac With JavaScript

TODO: Pull subtitle into page object
Code
#!/usr/bin/env osascript -l JavaScript

const sysEvents = Application("System Events")
const allProcesses = sysEvents.processes
const foregroundProcesses = allProcesses.whose({"backgroundOnly": {'=': false }})

for (let pIndex = 0; pIndex < foregroundProcesses.length; pIndex ++ ) {
  console.log(
    `${pIndex} - ` +
    `${foregroundProcesses[pIndex].name()} - ` +
    `${foregroundProcesses[pIndex].displayedName()}`
  )
}
Results
0 - Finder - Finder
1 - Google Chrome - Google Chrome
2 - sublime_text - Sublime Text
3 - GitHub Desktop - GitHub Desktop
4 - Vivaldi - Vivaldi
5 - Keychain Access - Keychain Access
6 - Soulver 3 - Soulver 3
7 - Stickies - Stickies
8 - iTerm2 - iTerm2
9 - Loopback - Loopback
10 - Activity Monitor - Activity Monitor
11 - Terminal - Terminal
12 - Electron - Code
13 - Spotify - Spotify
14 - TextEdit - TextEdit
15 - Adobe Photoshop 2023 - Adobe Photoshop 2023
16 - Safari - Safari
17 - firefox - Firefox

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

List The Foreground Apps Running On A Mac With JavaScript

-- code
-- osascript

#!/usr/bin/env osascript -l JavaScript

const sysEvents = Application("System Events")
const allProcesses = sysEvents.processes
const foregroundProcesses = allProcesses.whose({"backgroundOnly": {'=': false }})

for (let pIndex = 0; pIndex < foregroundProcesses.length; pIndex ++ ) {
  console.log(
    `${pIndex} - ` +
    `${foregroundProcesses[pIndex].name()} - ` +
    `${foregroundProcesses[pIndex].displayedName()}`
  )
}

-- results/

0 - Finder - Finder
1 - Google Chrome - Google Chrome
2 - sublime_text - Sublime Text
3 - GitHub Desktop - GitHub Desktop
4 - Vivaldi - Vivaldi
5 - Keychain Access - Keychain Access
6 - Soulver 3 - Soulver 3
7 - Stickies - Stickies
8 - iTerm2 - iTerm2
9 - Loopback - Loopback
10 - Activity Monitor - Activity Monitor
11 - Terminal - Terminal
12 - Electron - Code
13 - Spotify - Spotify
14 - TextEdit - TextEdit
15 - Adobe Photoshop 2023 - Adobe Photoshop 2023
16 - Safari - Safari
17 - firefox - Firefox

-- /results

-- notes

- Some display names are different from the
internally used names. For example, "Electron"
and "Code"


-- categories
-- Mac 
-- OSA Script 
-- Apple Script

-- metadata
-- date: 2023-02-26 18:40:02
-- id: 2miutiva
-- type: post
-- site: aws
-- status: published