Jake.codes

List Running Apps and Windows

Wednesday, May 14, 2014

I was playing around at window management with AppleScript and I made this simple script to return a list of every window and the apps that are open on your Mac. This could be useful for someone wanting to make something cool with AppleScript.

set theNames to ""
tell application "System Events"
    repeat with p in every process
        repeat with w in every window of p
            set theNames to name of p & ": " & name of w & "
" & theNames
        end repeat
    end repeat
end tell
return theNames

Example output:

AppleScript Editor: Untitled 2
AppleScript Editor: Untitled
AppleScript Editor: Library
AppleScript Editor: List of Apps and Windows
Tweetbot: Main Window
Safari: Glassboard
FluidApp: GroupMe
Flamingo: Flamingo
nvALT: nvALT
Contexts: Sidebar
Path Finder: AlfredRun