set white_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 white_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
Click the following link:
applescript://com.apple.scripteditor/?action=new&script=tell%20application%20%22System%20Events%22% 20to%20set%20theApps%20to%20%28name%20of%20every%2 0process%20whose%20visible%20is%20true%20and%20nam e%20is%20not%20%22Finder%22%20and%20name%20is%20no t%20%28my%20name%20as%20text%29%29%0D%0Drepeat%20w ith%20theApp%20in%20theApps%0D%09tell%20applicatio n%20theApp%20to%20quit%0Dend%20repeat%0D
Once you click the link above, Script Editor on your machine will have the script in a window. Save it to ~/Library/Scripts as an application, giving it any name you want, like Quit All Apps. Then open /Applications/Applescript/Applescript Utility and check the box that is labeled Show Script Menu In Menu Bar and quit Applescript Utility.
Now any time you want to quit all apps except hidden, background, Finder, and Script Editor, then just choose the script from the Script Menu in the upper right on the menu bar.
If you want to "unhide" all hidden apps so they would get quitted also, you would add the line
tell application "System Events" to set the visible of every process to true
at the beginning of the script.
Something like this:
Code:set white_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 white_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
This will not quit any applications that are "hidden".
You can change the variable "white_list" to suit your needs.
If you save it as a script (not an app) in "Library>Scripts" you can access it from the script menu.This seems to work BUT should i save it as an App or just a script. I saved it as an APp in /Library/Scripts/
Thanx for all help thus far by the way
If you save it as a script (not an app) in "Library>Scripts" you can access it from the script menu.
It you save it as an application you can run it by simply double clicking on it's icon.
So whatever is more convenient for you.![]()