确保应用程序在Mac OS X中运行


2

是否有简单的方法来确保某些gui应用程序正在运行(如果崩溃则重新启动)?

Answers:



1

是的,您可以使用AppleScript执行所需操作。

首先,打开AppleScript Editor( /Applications/Utilities/AppleScript Editor.app

然后将此代码插入编辑器:

tell application "System Events"
    repeat
        set running_apps to every application process's name
        if running_apps does not contain "TextEdit" then
            tell application "TextEdit" to activate
        end if
    end repeat
 end tell

更换 TextEdit 与您想要观看的应用程序。然后将其另存为应用程序,并在需要保持应用程序打开时运行您保存的应用程序。

希望这可以帮助!


0

Applescript可能是这个的方式。 这个网页 概述了如何查看应用程序是否正在运行 这个网页 概述了如何运行应用程序以及如何根据条件执行操作。 基本上你会编写脚本,以便循环检查以查看应用程序是否正在运行。如果它在任何时候没有运行,你就会启动它。我会为你起草一些东西,但此时我还没有一台正在测试的Mac。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.