Applescript不会自动退出

时间:2012-07-01 20:16:01

标签: applescript

有什么办法可以让我的脚本自动关闭吗?注意:如果您强行退出,屏幕保护程序将保留在桌面上,因此不是因为它在应用程序中运行。

tell application "System Events"
    tell screen saver preferences
        if running then
            do shell script "killall ScreenSaverEngine"
        else
            do shell script "//System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background"
        end if
    end tell
end tell

1 个答案:

答案 0 :(得分:1)

&> /dev/null &添加到shell脚本:

tell application "System Events"
    tell screen saver preferences
        if running then
            do shell script "killall ScreenSaverEngine"
        else
            do shell script "//System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background  &> /dev/null &"
        end if
    end tell
end tell