Objective c 键盘不是';使用AppleScript解锁OS-X(Mavericks)后的t响应

Objective c 键盘不是';使用AppleScript解锁OS-X(Mavericks)后的t响应,objective-c,macos,applescript,osx-mavericks,Objective C,Macos,Applescript,Osx Mavericks,我正在使用AppleScript从外部设备(触发器)锁定Mac,并从同一设备解锁它 锁定效果很好,但当解锁我的Mac键盘和键盘时,会变得无响应。奇怪的是,当我在锁定后移动鼠标并获得密码登录时,如果我输入密码,解锁会使键盘响应,只有这样 这是我不知道的安全设置吗?我该怎么解决呢 以下是我正在使用的脚本: 锁定: 解锁: tell application "System Events" tell security preferences set require password to wake to

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

锁定效果很好,但当解锁我的Mac键盘和键盘时,会变得无响应。奇怪的是,当我在锁定后移动鼠标并获得密码登录时,如果我输入密码,解锁会使键盘响应,只有这样

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

以下是我正在使用的脚本:

锁定:

解锁:

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日):我没有找到任何解决方案,bounty也完成了,所以我要做的是使用ActionScript插入我的密码(也许这可以帮助其他有同样问题的人)。如果您有其他解决方案,我很想知道。

请尝试下面锁定屏幕的方法,我使用的是相同的方法,在锁定或解锁时没有问题。希望这有帮助

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

今天晚些时候,我将能够在Mavericks机器上进行更多测试。同时,我有一个小理论——你有没有用其他“活动”屏幕保护程序测试过这个问题?我这么说是因为我确实有几个屏幕保护程序有点问题,我知道其中至少有一个需要为小牛更新。你用哪一种

[更新:]我确实了解了小牛队,没有看到您描述的问题,或者至少没有看到如此严重的问题。不过,我确实有点奇怪,可能是因为时间关系。如果你这样构造你的脚本呢?对我来说,它涵盖了诸如“连接无效”之类的错误(我承认这有点“危险”;最好设置一个上限,即通过在其中放置计数器来“尝试激活”的次数):


它可以工作,但我的问题是将require密码设置为true。所以当我使用你的代码时,我得到了相同的结果。添加时的含义:告诉安全首选项\n设置要求密码唤醒为true\n结束告诉\n在第二行下面我遇到相同的问题。如果我从代码中删除这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
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