0

在 Mac Lion 中:在锁屏图标中选择锁屏(钥匙串访问 -> 首选项 -> 常规 -> 显示钥匙串 ...),它将处于屏幕保护模式。

在小牛:通过上述步骤锁定屏幕时,它不是处于屏幕保护模式。所以我们无法控制它。不知道为什么???

然后在锁定屏幕中,我将事件转移到在 MAVERICKS 上按下键(在 Mac Lion 上没问题),但似乎对此一无所知:

 on run
      tell application "/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app" to quit
      tell application "System Events" to key code 125
      delay 1
      tell application "System Events" to keystroke "password"
      delay 1
      tell application "System Events" to keystroke return
      delay 5
 end run

通过以下方式执行上述脚本:

    NSString *source = [NSString stringWithFormat:kAppleScriptUnlockWithPassword ,password];

    // Create unlock script with password
    NSAppleScript* appleScript = [[NSAppleScript alloc] initWithSource:source];
    NSDictionary * errDic = nil;
    // Execute script
    [screenState removeAllObjects];
    [appleScript executeAndReturnError:&errDic];

    NSLog(@"%@", errDic);

它返回:

{
    NSAppleScriptErrorAppName = "System Events";
    NSAppleScriptErrorBriefMessage = "Can\U2019t make {1, \"\"} into type text.";
    NSAppleScriptErrorMessage = "System Events got an error: Can\U2019t make {1, \"\"} into type text.";
    NSAppleScriptErrorNumber = "-1700";
    NSAppleScriptErrorRange = "NSRange: {92, 20}";
}

你有什么想法吗?

请帮我。

谢谢

4

1 回答 1

1

keystroke 125插入 125 作为文本。尝试key code改用:

quit application "ScreenSaverEngine"
tell application "System Events"
    key code 125
    delay 1
    keystroke "password" & return
end tell
于 2013-10-30T14:22:56.867 回答