Last active
July 18, 2022 19:16
-
-
Save jeffehobbs/c2c4b75328d6a69fe80d538a51227107 to your computer and use it in GitHub Desktop.
AppleScript to quit all open Applications on MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" to set the visible of every process to true | |
set allow_list to {"Finder"} | |
try | |
tell application "Finder" | |
set process_list to the name of every process whose visible is true | |
end tell | |
repeat with i from 1 to (number of items in process_list) | |
set this_process to item i of the process_list | |
if this_process is not in allow_list then | |
tell application this_process | |
quit | |
end tell | |
end if | |
end repeat | |
on error | |
tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0 | |
end try |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment