Needed a bit of advice. What’s the best way to change the color of the selected object in Preview, per this video: http://d.pr/mHfG/TH4It1Sy
I know how to get the markup toolbar to open, but changing the colors is a challenge. Peter’s suggestion was “relative to window, pause, click” or Applescript but suggested that I ask here.
Not sure how I would do this with AppleScript, although that’d be nice and direct if possible.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Keyboard Maestro Engine"
set btnNum to (getvariable "zzzColorButtonNumber") as integer
end tell
tell application "System Events"
tell application process "Preview"
tell first window
tell (first toolbar whose description is "toolbar")
if value of (first checkbox whose description is "Markup") is 0 then
tell (first checkbox whose description is "Markup")
perform action "AXPress"
end tell
end if
end tell
tell (first toolbar whose description is "edit toolbar")
tell (first color well whose description is "Border color")
perform action "AXPress"
tell first pop over
tell (first UI element whose description is "grid")
tell button btnNum
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
The script takes the color button number from a KM variable.
On one of my Macs (although not the other one), I now get an error when running this AppleScript. The error is as follows. Any ideas?
osascript: OpenScripting.framework - scripting addition “/Library/ScriptingAdditions/Adobe Unit Types.osax” cannot be used with the current OS because it has no OSAXHandlers entry in its Info.plist.
/var/folders/tl/4gngpls16hs08fhcm21991jr0000gn/T/Keyboard-Maestro-Script-8B7F3714-BC0F-4D79-AEAB-1FAA4126A24E:359:375: execution error: System Events got an error: Can’t get toolbar 1 of window 1 of application process “Preview” whose description = “toolbar”. Invalid index. (-1719)
Hi Tom - thank you for the response! I updated the Adobe Unit Types file per that previous post, and now get this error. Any ideas?
/var/folders/tl/4gngpls16hs08fhcm21991jr0000gn/T/Keyboard-Maestro-Script-B0E3DC75-6731-41DA-AD44-07C341154E65:359:375: execution error: System Events got an error: Can’t get toolbar 1 of window 1 of application process “Preview” whose description = “toolbar”. Invalid index. (-1719)
Thank you for the response! Looks like restarting Preview fixed it. Greatly dislike the bugs within MacOS these days, but greatly appreciate your help!