使用AppleScript解锁OS-X(Mavericks)后,键盘无响应

7
我正在使用AppleScript从外部设备(触发器)锁定Mac,并从此设备解锁它。
锁定功能很好,但是当我解锁我的Mac时,键盘和触控板变得不响应。奇怪的是,当我在锁定后移动鼠标并获取密码登录时,如果我输入密码,解锁会使键盘变得响应,然后才能正常使用。
这是一种我不知道的安全设置吗?我该如何解决?
以下是我正在使用的脚本:
锁定:
tell application "System Events"
tell security preferences
set require password to wake to true
end tell
end tell

activate application "ScreenSaverEngine"

解锁:

tell application "System Events"
tell security preferences
set require password to wake to false
end tell
end tell

tell application "ScreenSaverEngine" to quit

请帮忙,我非常绝望。另外,如果您知道其他用代码锁定/解锁我的Mac的方法,我很愿意尝试一下!
谢谢!
更新:明确一下,当删除密码设置代码(需要密码)时,问题不会出现。也就是说,删除这三行代码:
tell security preferences
    set require password to wake to true
end tell

这个问题并不存在,这就是为什么我认为可能涉及到我不知道的某些安全性问题。

更新(2013年12月26日):我没有找到任何解决方案,赏金也已经结束,所以我的做法是使用ActionScript插入我的密码(或许这对其他遇到同样问题的人有帮助)。如果你有其他的解决方案,我很愿意了解。

2个回答

3

今天晚些时候我将能够在一台Mavericks机器上进行更多测试。同时,我有一个小理论--您是否尝试使用其他“活动”的屏幕保护程序进行测试?我这么说是因为我有几个有点故障的屏幕保护程序,我知道其中至少一个需要更新以适用于Mavericks。您使用的是哪一个?

[更新:]我已经在Mavericks上测试过,并没有看到您所描述的问题,或者至少没有严重的问题。不过我遇到了一些奇怪的现象,可能与时间有关。如果您像这样构建脚本呢?对我来说,它可以弥补“连接无效”之类的错误(我承认这有点'危险';也许最好在那里放一个计数器来限制尝试激活的次数):

tell application "System Events"
    tell security preferences
        set require password to wake to false
    end tell
end tell
set connectionValid to false
repeat until connectionValid
    try
        activate application "ScreenSaverEngine"
        set connectionValid to true
    on error e
    end try
end repeat

3

尝试以下方法锁定屏幕,我正在使用相同的方法,锁定和解锁时没有任何问题。希望这能帮到你。

try
tell application "System Events"
    set the process_flag to (exists process "ScreenSaverEngine")
end tell
if the process_flag is true then
    ignoring application responses
        tell application "System Events" to quit
    end ignoring
else
    set the target_app to ((path to "dlib" from system domain as string) & "Frameworks:ScreenSaver.framework:Versions:A:Resources:ScreenSaverEngine.app") as alias
    tell application (target_app as string) to launch
end if
end try

它可以工作,但我的问题在于将所需密码设置为true。因此,当我使用您的代码执行此操作时,我会得到相同的结果。也就是说,在添加以下内容时: tell security preferences\n set require password to wake to true\n end tell\n在第二行下面,我遇到了同样的问题。如果我从我的代码中删除这3行,它也与您的代码一样工作。抱歉我没有表达清楚。 您有什么线索可以解决这个问题吗? - Idan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接