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

Ida*_*dan 7 macos applescript objective-c osx-mavericks

我正在使用AppleScript从外部设备(触发器)锁定Mac并从同一设备解锁.

锁定效果很好,但解锁时我的Mac键盘和打击垫变得无法响应.奇怪的是当我在锁定后移动慕斯并获得密码登录时,如果我输入密码,则解锁使键盘响应并且只有这样.

这是我不知道的某种安全设置吗?我该怎么解决?

这是我正在使用的脚本:

锁:

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

activate application "ScreenSaverEngine"
Run Code Online (Sandbox Code Playgroud)

开锁:

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

tell application "ScreenSaverEngine" to quit
Run Code Online (Sandbox Code Playgroud)

请帮助我绝望.此外,如果您有其他方法,您知道使用代码锁定/解锁我的Mac,我很乐意尝试一下!

谢谢!

更新:要清除密码设置代码(需要密码)时,问题不会出现.意思是删除这3行:

tell security preferences
    set require password to wake to true
end tell
Run Code Online (Sandbox Code Playgroud)

没有这个问题,这就是为什么我认为它可能是一些我不知道的安全问题.

更新(2013年12月26日):我没有找到任何解决方案和赏金完成所以我正在做的是使用ActionScript插入我的密码(也许这可以帮助其他人有同样的问题).如果您有其他解决方案,我很乐意知道.

Kir*_*gar 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
Run Code Online (Sandbox Code Playgroud)