gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 02:48:06 24 4
gpt4 key购买 nike

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

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

谢谢!

最佳答案

尝试这个:

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

关于macos - Applescript 获取正在运行的应用程序列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18372328/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com