Skip to content

Instantly share code, notes, and snippets.

@mcbrwr
Created February 13, 2016 21:07
Show Gist options
  • Save mcbrwr/89987b4bca562d730d3d to your computer and use it in GitHub Desktop.
Save mcbrwr/89987b4bca562d730d3d to your computer and use it in GitHub Desktop.
name all open applications and count their open windows
tell application "System Events"
repeat with theProcess in processes
if not background only of theProcess then
tell theProcess
set processName to name
set theWindows to windows
end tell
set windowsCount to count of theWindows
if processName is not "Finder" and processName is not "Automator" then
say processName
say windowsCount as text
if windowsCount is greater than 0 then
repeat with theWindow in theWindows
say "found a window of " & processName
tell theProcess
set frontmost to true
tell theWindow
click button 2
end tell
end tell
end repeat
end if
end if
end if
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment