I am a complete beginner to Mac scripting.
To learn GUI scripting, I set the following goal for myself : have an Applescript emulate what happens
when a file is opened in Preview, the “Go to Page …” menu item is clicked and the user goes to page 3.
Here is my failed attempt :
tell application "Preview" to open "some:path:my_file.pdf"
tell application "System Events"
tell process "Preview"
set frontmost to true
click menu item "Go to Page…" of menu "Go" of menu bar 1
set value of text field 1 of window 1 to "3"
tell application "System Events"
key code 36
end tell
end tell
end tell
and here is the error message I get :
error “System Events got an error: Can’t get text field 1 of window 1 of process "Preview". Invalid index.” number -1719 from text field 1 of window 1 of process “Preview”
Model: MacBook Air
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14