I've resorted to a GUI method to open the files, but am trying now to open the header and footer panel, without success.
set theItem to ((path to desktop) & "This is a test.pdf") as text
set theitem2 to POSIX path of theItem
tell application "Adobe Acrobat Pro"
activate
tell application "Finder"
repeat until exists process "Acrobat"
delay 0.1
end repeat
end tell
delay 1
close all docs saving no
tell application "System Events" to tell process "Acrobat"
click menu item 1 of menu 1 of menu bar item 3 of menu bar 1
set x to 0
repeat while not (exists (window "Open"))
delay 0.1
set x to x + 1
if x ≥ 20 then exit repeat
end repeat
keystroke theitem2
click button "Go" of sheet 1 of window "Open"
click button "Open" of window "Open"
end tell
repeat until exists active doc
delay 0.1
end repeat
tell application "System Events" to tell process "Acrobat"
click menu item "Tools" of menu 1 of menu bar item "View" of menu bar 1
click menu item 1 of menu of menu item "Tools" of menu 1 of menu bar item "View" of menu bar 1
try
# this one works, opens the Tools panel
tell UI element 2 of group 1 of outline 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1
set {xPosition, yPosition} to position
set {xSize, ySize} to size
end tell
-- modify offsets if hot spot is not centered:
click at {xPosition + (xSize div 2), yPosition + (ySize div 2)}
delay 1
# this one doesn't work, trying to click the "Header & Footer" tool button
tell menu button "Header & Footer" of group 1 of group "Pages" of outline "Tools" of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1
set {xPosition, yPosition} to position
set {xSize, ySize} to size
end tell
-- modify offsets if hot spot is not centered:
click at {xPosition + (xSize div 2), yPosition + (ySize div 2)}
end try
end tell
say active tool as text -- returns 'select'
try
say toolbar visibility as text
set active tool to "Tools" -- "Add Header & Footer…" --fails
on error errmsg
display dialog errmsg
end try
display dialog theItem as alias as text
--close all docs saving no
end tell