14

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

どんな助けでも大歓迎です!

ありがとう!

4

8 に答える 8

20

これを試して:

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
于 2013-08-22T05:51:24.313 に答える
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

ここに画像の説明を入力

于 2013-08-22T07:17:25.687 に答える
5

はるかに簡単なこのスクリプトを使用できます

tell application "Finder"
    get the name of every process whose visible is true
end tell
于 2015-07-29T15:04:46.847 に答える
1

& (name of every process whose (name is "AppName")Michele PercichParag Bafna のソリューションに追加して、特定のメニュー バー アプリケーションを名前で含めることができます。

tell application processName to quitの代わりに使用できます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
于 2015-05-09T18:05:09.470 に答える
1

これを試すことができます

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
于 2013-08-22T06:02:02.797 に答える