2013-10-30 89 views
0

在Mac獅子(下鍵):選擇鎖屏圖標鎖屏(鑰匙串訪問 - >首選項 - >常規 - >顯示鑰匙扣......),它會在屏幕保護模式。的AppleScript:擊鍵125小牛

在小牛:當由上述步驟鎖屏,它不在屏幕保護模式。所以我們無法控制它。我不知道爲什麼?通過

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 

EXCUTE上面的腳本:

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); 

然後在鎖定屏幕,我轉院事件按向下鍵在小牛隊(這是確定在Mac獅子),但似乎並不知道這件事

它返回:

{ 
    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}"; 
} 

你有任何想法?

請幫幫我。

感謝

+0

您是否收到任何錯誤?對我來說,它的工作很好。 (激活屏幕保護程序) –

+0

我更新的說明,請大家幫我檢查一遍。謝謝 –

回答

1

keystroke 125刀片125爲文本。嘗試使用key code代替:

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