I am looking to use a hot key to kill all applications - different from Quit, in the sense that I would just want to kill all running programs that would show up in COMMAND/OPTION/ESCAPE. I am not looking for an elegant “quit” scenario where I am prompted whether I really want to close a given program that might be in the middle of something.
I see that “Close All Applications” is available, but there is no choice to “kill” the applications for that scenario (as far as I can tell).
I could write a KM macro to COMMAND?OPTION/ESCAPE, and then go through mouse movements and clicks to close apps. But I was hoping there might be something more elegant and to-the-point - either through something I am not seeing in KM, or maybe through Perl, Python, or some other command line code that I could roll into KM or Automator.
No, there is no Force Quit or Kill "All Applications.
There is a Force Quit variant of the Quit Application action, so you could use a sequence of these listing out all the apps you normally have running, and adding any as you notice any not being quit.
Note that it is generally a very bad idea to kill or force quit an application. The potential for loss of data is quite large - even previously “saved” data can become corrupted if you kill an application. It should only be used as a last resort, so “Force Quit All Applications” would almost always be a terrible idea.
I don’t see a way to tell what apps are NOT background-only using the shell, but it can be done with easily enough with AppleScript. Then you can compose a shell script with the resulting PIDs and run that via AppleScript or with an Execute Shell Action in Keyboard Maestro.
tell application "System Events"
set procIDList to unix id of every process whose background only is false
set AppleScript's text item delimiters to " "
set procIDList to procIDList as text
set shellCMD to "kill " & procIDList
# Uncomment the following line to run the command. (KNOW WHAT YOU ARE DOING!)
# do shell script shellCMD