I want to script the "Preview" application to do the equivalent of clicking the +
or -
button in the app, which when hovered over give the text "Scale document up" (and down). Is this possible?
More generally though, is there a way to see what events an application listens to that can be osascript
"told"? In other words, what are all valid values of 'x' below for a given application "App"?
osascript -e 'tell application "App" to x'
Answering just the more general question:
In other words, what are all valid values of 'x' below for a given application "App"?
osascript
is AppleScript. AppleScript commands come from the Dictionary in the target application. Load the target application's Dictionary into Script Editor (or Script Debugger) to see what they are.
Returning now to the specific question:
I want to script the "Preview" application to do the equivalent of clicking the + or - button in the app, which when hovered over give the text "Scale document up" (and down). Is this possible?
No. The Preview application is not scriptable in any useful sense (beyond basic things like "I've got a window"). You would need to script SystemEvents to choose the Zoom In / Zoom Out menu item for you (or to send the corresponding keyboard shortcut). Here's a script, suitable for running in Script Editor, that demonstrates:
tell application "Preview" to activate
tell application "System Events"
tell application process "Preview"
tell menu bar 1
tell menu bar item "View"
tell menu 1
click menu item "Zoom In"
end tell
end tell
end tell
end tell
end tell
You'd need to adapt that for use in osascript
.