AppleScript:小牛队的击键125(向下键)

时间:2013-10-30 10:42:13

标签: applescript osx-mavericks

在Mac Lion中:选择锁屏图标(Keychain Access - > Preferences - > General - > Show keychain ...)中的锁屏,它将处于屏幕保护模式。

在小牛队中:当按上述步骤锁定屏幕时,它不在屏幕保护模式下。所以我们无法控制它。我不知道为什么???

然后在锁定的屏幕中,我转移事件按下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}";
}

你对此有什么想法吗?

请帮帮我。

由于

1 个答案:

答案 0 :(得分:1)

keystroke 125将125插入为文本。请尝试使用key code

quit application "ScreenSaverEngine"
tell application "System Events"
    key code 125
    delay 1
    keystroke "password" & return
end tell