0

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

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
4

1 回答 1

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
于 2012-07-01T20:28:59.610 回答