Here a quick adaptation of my old script, to change the Markup Text Color:
Preview: Change markup text color.kmmacros (3.5 KB)
(also updated to use local variables)
AppleScript as text:
tell application id "com.stairways.keyboardmaestro.engine"
set inst to system attribute "KMINSTANCE"
set btnNum to (getvariable "Local Color Button Number" instance inst) as number
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 button whose description is "Text Style")
perform action "AXPress"
tell first pop over
tell first color well
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
end tell
end tell