gpt4 book ai didi

macos - 使用 Applescript 退出所有应用程序?

转载 作者:行者123 更新时间:2023-12-03 07:32:24 26 4
gpt4 key购买 nike

如何使用 Applescript 退出所有正在运行的用户应用程序?

最佳答案

没关系...我想我找到了答案:

tell application "System Events" to set the visible of every process to true

set white_list to {"Finder"}

try
tell application "Finder"
set process_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in process_list)
set this_process to item i of the process_list
if this_process is not in white_list then
tell application this_process
quit
end tell
end if
end repeat
on error
tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0
end try

关于macos - 使用 Applescript 退出所有应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/495323/

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