Skip to content

Instantly share code, notes, and snippets.

@kfdm
Created September 15, 2011 14:21
Show Gist options
  • Save kfdm/1219357 to your computer and use it in GitHub Desktop.
Save kfdm/1219357 to your computer and use it in GitHub Desktop.
Quickly close open programs
-- Taken from http://stackoverflow.com/questions/495323/quit-all-applications-using-applescript/495346#495346
tell application "System Events" to set the visible of every process to true
set white_list to {"Finder", "Adium", "iTunes", "Transmission", "HardwareGrowler", "AppleScript Editor"}
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)
try
set this_process to item i of the process_list
if this_process is not in white_list then
tell application this_process to quit
do shell script "/usr/local/bin/growlnotify -m 'Quitting " & this_process & "'"
end if
on error
do shell script "/usr/local/bin/growlnotify -m 'Error quitting " & this_process & "'"
end try
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment