2017-07-27 163 views
0

我需要一個小小的applescript來打開密碼保護的pdf。如何使用applescript打開受密碼保護的PDF?

我不知道如何訪問密碼文本字段。

的代碼我有:

set elPdf to ("Path:to:my:file.pdf") 
activate application "Preview" 

tell application "Preview" 
    open elPdf 
    delay 1 
    tell application "System Events" 
     set value of text field 1 to "password" 
     keystroke return 
    end tell 
end tell 

AppleScript的是沒有找到文字/密碼字段,甚至當我添加「表1」和「窗口1」

如何我訪問帶有applescript的preview.app pdf的密碼字段?

回答

0

我會嘗試通過菜單欄訪問密碼輸入:

set myFolder to path to desktop as string 
set myFile to myFolder & "trial.pdf" 

tell application "Preview" 
    open myFile 
    activate 
end tell 

tell application "System Events" 
    tell process "Preview" 
    tell menu bar 1 
     tell menu bar item "File" 
     tell menu "File" 
      click menu item 13 
      keystroke "34ue8XD5mM" 
      keystroke return 
     end tell 
     end tell 
    end tell 
    end tell 
end tell 
+0

跆拳道?你怎麼猜我的密碼? ;-)工作很好。現在我該如何防止預覽從我的pdf導出... – afg