Applescript获取正在运行的应用程序列表?

use*_*399 10 macos applescript osx-mountain-lion

Applescript新手问题:)我正在尝试创建一个小AppleScript,允许我从当前运行的应用程序列表中选择多个项目,然后退出所选的应用程序.这样的东西可以工作,但不必点击每个对话框,从列表中选择会更容易.

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
Run Code Online (Sandbox Code Playgroud)

任何和所有的帮助将不胜感激!

谢谢!

Mic*_*ich 13

试试这个:

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
Run Code Online (Sandbox Code Playgroud)


Par*_*fna 6

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
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


Mah*_*dam 5

你可以使用这个简单得多的脚本

tell application "Finder"
    get the name of every process whose visible is true
end tell
Run Code Online (Sandbox Code Playgroud)