如何使用applescript打开受密码保护的PDF?

时间:2017-07-27 16:33:01

标签: 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和#34;和"窗口1"

如何使用applescript?

访问preview.app pdf的密码字段

1 个答案:

答案 0 :(得分: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