使用 Applescript 退出所有应用程序? [英] Quit All Applications using Applescript?

查看:30
本文介绍了使用 Applescript 退出所有应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How would I quit all running user applications using Applescript?

推荐答案

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

It's okay... I think I found my answer:

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

这篇关于使用 Applescript 退出所有应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆