Skip to content

Instantly share code, notes, and snippets.

@alanhg
Created January 20, 2021 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanhg/524ad85896219036034bfe81f76df209 to your computer and use it in GitHub Desktop.
Save alanhg/524ad85896219036034bfe81f76df209 to your computer and use it in GitHub Desktop.
hide app app
tell application "System Events" to set all_apps to the name of every process whose visible is true
repeat with a in all_apps
tell application a to try
repeat with w in (get every window)
set miniaturized of w to true
end repeat
on error
activate
tell application "System Events" to repeat (count windows of process a) times
keystroke "m" using command down
delay 0.1
end repeat
end try
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment