Skip to content

Instantly share code, notes, and snippets.

@duraki
Forked from Teraflopst/hide-all-app.scpt
Created October 3, 2022 19:36
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 duraki/84667a1f94fb61ead4a21f2508920c97 to your computer and use it in GitHub Desktop.
Save duraki/84667a1f94fb61ead4a21f2508920c97 to your computer and use it in GitHub Desktop.
AppleScript: Hide all applications and show the desktop on Mac
tell application "Finder"
set visible of every process whose visible is true and name is not "Finder" to false
set the collapsed of windows to true
end tell
set appName to "Mail"
set startIt to false
tell application "System Events"
if not (exists process appName) then
set startIt to true
else if frontmost of process appName then
set visible of process appName to false
else
set frontmost of process appName to true
end if
end tell
if startIt then
tell application appName to activate
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment