This AppleScript works here:
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.
Here the complete macro:
_[test] Select Border Color in Preview.kmmacros (3.0 KB)
Instructions:
- Set the desired color button number in the green action of the macro.
- The color buttons are the color fields in Preview’s color well. They are numbered from left to right, top to bottom.
- Make sure your document is open in Preview.
- Launch the macro.