Applescript获取正在运行的应用程序列表?
问题描述:
Applescript新手问题:)我试图创建一个小applescript,使我可以从当前运行的应用程序列表中选择多个项目,然后退出那些选定的应用程序.这样的事情是可行的,但是不必从每个对话框中单击,而是从列表中选择要容易得多.
Applescript newbie question again :) I am trying to create a small applescript that will allow me to select multiple items from a list of currently running applications and then quit those selected apps. Something like this works but rather than having to click on each dialog it would be much easier to chose from a 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 and all help would be greatly appreciated!
谢谢!
答
尝试一下:
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