在Mountain Lion中从AppleScript激活屏幕保护程序


9

我有一个用来激活屏幕保护程序的脚本,该脚本在Mountain Lion中不再起作用。

这是一个称为AppleScript脚本的shell脚本:

#!/bin/bash
osascript /Users/lorin/scripts/lockscreen.scpt

lockscreen.scpt文件如下所示:

tell application "ScreenSaverEngine" 
        activate 
end tell

如果lockscreen.scpt在AppleScript编辑器中启动,则会弹出“选择应用程序”对话框,询问“ ScreenSaverEngine在哪里?”。

有人知道Mountain Lion-y激活屏幕保护程序的方法吗?

Answers:


15

这是启动随机屏幕保护程序的好方法。但是,如果您只想启动活动的屏幕保护程序,则可以在Mountain Lion中使用它:

tell application "System Events" 
    start current screen saver
end tell

7

这在ML中有效:

tell application "System Events"
    set ss to screen saver "Random"
    start ss
end tell

可以用您选择的“ Flurry”或“ Shell”等替换“ Random”。

来源披露:http : //hintsforums.macworld.com/showthread.php?t=111478


如何使其停止屏幕保护程序?我尝试过tell application "System Events" to stop screen saver
Jayen

@Jayentell application "System Events" to quit current screen saver
wrtsprt

3

tell application "ScreenSaverEngine" to run


我有问题tell application "System Events" to start current screen saver。如果我使用键盘绑定多次运行该脚本,则我会堆叠多个屏保,只有第一个会关闭。但是,这个答案对我来说非常有效。
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.