As there is a free scriptable app able to open PDF I don't use Preview when I face this kind of need.
set thePDF to (path to desktop folder as text) & "abc.pdf"
set thePassWord to "abc"
--tell application "Finder" to open file thePDF using application id "net.sourceforge.skim-app.skim"
tell application "Skim" to open file thePDF
tell application "System Events" to tell process "Skim"
set frontmost to true
tell window 1
class of UI elements
--> {splitter group, button, button, button, toolbar, image, menu button, static text}
tell first splitter group
class of UI elements
--> {radio group, text field, scroll area, splitter, splitter group, splitter, radio group, text field, scroll area}
tell first splitter group
class of UI elements
--> {scroll area, static text, static text, image, text field}
tell first text field
properties
--> {minimum value:missing value, orientation:missing value, position:{2168, 656}, class:text field, role description:"champ de texte sécurisé", accessibility description:missing value, focused:true, title:missing value, size:{241, 22}, value:"", help:missing value, enabled:true, maximum value:missing value, role:"AXTextField", entire contents:{}, subrole:"AXSecureTextField", selected:missing value, name:missing value, description:"champ de texte sécurisé"}
keystroke thePassWord & return
end tell
end tell
end tell
end tell
end tell
Of course, it's a very bad idea to store a password in a script but I'm just showing how to enter it.
Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) vendredi 15 avril 2016 12:14:43