Applescript get a list of running applications?

New question about Applescript new :) I'm trying to create a small applescript that will allow me to select several items from the list of running applications and then exit the selected applications. Something like this works, but instead of clicking on each dialog, it would be much easier to select from the list.

tell application "System Events" repeat with p in every process if background only of p is false then display dialog "Would you like to quit " & name of p & "?" as string end if end repeat end tell 

Any help would be greatly appreciated!

Thanks!

+7
applescript osx-mountain-lion macos
source share
5 answers

Try the following:

 tell application "System Events" set listOfProcesses to (name of every process where background only is false) tell me to set selectedProcesses to choose from list listOfProcesses with multiple selections allowed end tell --The variable `selectedProcesses` will contain the list of selected items. repeat with processName in selectedProcesses do shell script "Killall " & quoted form of processName end repeat 
+11
source share
 tell application "System Events" set processList to get the name of every process whose background only is false set processNameList to choose from list processList with prompt "Select process to quit" with multiple selections allowed if the result is not false then repeat with processName in processNameList do shell script "Killall " & quoted form of processName end repeat end if end tell 

enter image description here

+5
source share

you can use this script which is much easier

 tell application "Finder" get the name of every process whose visible is true end tell 
+2
source share

You can try this

 tell application "System Events" set AppName to name of every process whose background only is false choose from list AppName OK button name "Ok" cancel button name "Cancel" end 
+1
source share

& (name of every process whose (name is "AppName") can be added to and Parag Bafna to include specific applications in the menu by name.

tell application processName to quit can be used instead of do shell script "Killall " & quoted form of processName .

 tell application "System Events" set processList to Β¬ (name of every process where background only is false) & Β¬ (name of every process whose Β¬ (name is "AppName") or Β¬ (name is "AnotherAppName")) tell me to set selectedProcesses to choose from list processList with prompt "Select process(es) to quit:" with multiple selections allowed end tell if the result is not false then repeat with processName in selectedProcesses tell application processName to quit end repeat end if 
+1
source share

All Articles