Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator "Quit All Applications"

I've created a 'Quit All' app using macOS' automator app which quits all open applications. Sometimes however, I don't want ALL apps to quit - Is there some way for the application to ask me which apps I don't want to quit, then quit the rest?

Posted on Aug 5, 2020 12:24 PM

Reply
Question marked as Best reply

Posted on Aug 5, 2020 2:34 PM

> Is there some way for the application to ask me which apps I don't want to quit


Not using Automator directly, no.


Automator has very little logic processing - it's very linear and any time you want to change the workflow based on some arbitrary condition (such as a user selection), it's a PITA.


It is easy to do via AppleScript, and you can embed your AppleScript in an Automator 'Run AppleScript' action.


Put this in a Run AppleScript action and see how it goes:


tell application "System Events"
	-- get a list of open apps:
	set appNames to name of every application process whose visible is true
end tell

-- prompt the user for which apps to quit
set appsToQuit to choose from list appNames default items appNames with prompt "Which apps would you like to quit?" with multiple selections allowed

-- name sure we didn't cancel:
if appsToQuit is not false then
	-- iterate through the selected apps
	repeat with eachApp in appsToQuit
		-- and tell each one to quit
		tell application eachApp to quit
	end repeat
end if


2 replies
Question marked as Best reply

Aug 5, 2020 2:34 PM in response to jasonJackieNienaber

> Is there some way for the application to ask me which apps I don't want to quit


Not using Automator directly, no.


Automator has very little logic processing - it's very linear and any time you want to change the workflow based on some arbitrary condition (such as a user selection), it's a PITA.


It is easy to do via AppleScript, and you can embed your AppleScript in an Automator 'Run AppleScript' action.


Put this in a Run AppleScript action and see how it goes:


tell application "System Events"
	-- get a list of open apps:
	set appNames to name of every application process whose visible is true
end tell

-- prompt the user for which apps to quit
set appsToQuit to choose from list appNames default items appNames with prompt "Which apps would you like to quit?" with multiple selections allowed

-- name sure we didn't cancel:
if appsToQuit is not false then
	-- iterate through the selected apps
	repeat with eachApp in appsToQuit
		-- and tell each one to quit
		tell application eachApp to quit
	end repeat
end if


Automator "Quit All Applications"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.