I am trying to work out a way to change the text colour for the Annotation Markup Text in Preview. I've tried using Found Image to get at the colour grid for Markup Text in Preview but it's not reliable.
This is what the grid looks like. There is no native way within Preview (that I have found) to get here without using the Mouse to open up the nested panels.
There is a solution for changing the Border Colour already on the Forum by @Tom using AppleScript but I haven't been able to adapt this from Border to Font/Text Colour.
Anyone been able to achieve this? Thanks for any help.
application Process "Preview"
window myimage.jpg
splitter group 1
scroll area 1
toolbar 1
menu button "View"
radio group 1
menu button 1
static text "View"
group 1
group "Zoom"
button 1
button 2
static text "Zoom"
button "Zoom to Fit"
menu button "Share"
radio group 1
menu button 1
static text "Share"
checkbox "Markup"
group 2
radio group "Highlight"
radio button 1
menu button 1
static text "Highlight"
radio button "Rotate"
group 3
text field "Search"
button 1
static text "Search"
toolbar 2
group 1
menu button 1
group 2
checkbox 1
checkbox 1
checkbox 2
button 1
button 2
button 3
group 3
checkbox 1
group 4
checkbox 1
button 4
color well 1
image 1
color well 2
image 2
button 5
pop over 1
pop up button 1
text field 1
incrementor 1
button 1
button 2
group 1
checkbox 1
checkbox 2
checkbox 3
color well 1
pop over 1
button "Show Colors…"
UI element 2
button 1
button 2
button 3
button 4
button 5
button 6
button 7
button 8
button 9
button 10
button 11
button 12
button 13
button 14
button 15
button 16
button 17
button 18
button 19
button 20
button 21
button 22
button 23
button 24
button 25
button 26
button 27
button 28
button 29
button 30
button 31
button 32
button 33
button 34
button 35
button 36
button 37
button 38
button 39
button 40
button 41
button 42
button 43
button 44
button 45
button 46
button 47
button 48
button 49
button 50
button 51
button 52
button 53
button 54
button 55
button 56
button 57
button 58
button 59
button 60
button 61
button 62
button 63
button 64
button 65
button 66
button 67
button 68
button 69
button 70
button 71
button 72
button 73
button 74
button 75
button 76
button 77
button 78
button 79
button 80
button 81
button 82
button 83
button 84
button 85
button 86
button 87
button 88
button 89
button 90
button 91
button 92
button 93
button 94
button 95
button 96
button 97
button 98
button 99
button 100
button 101
button 102
button 103
button 104
button 105
button 106
button 107
button 108
button 109
button 110
button 111
button 112
button 113
button 114
button 115
button 116
button 117
button 118
button 119
button 120
UI element 3
button 1
button 2
button 3
button 4
button 5
button 6
button 7
button 8
button 9
button 10
button 11
button 12
group 2
checkbox 1
checkbox 2
checkbox 3
checkbox 4
static text "—"
button 1
button 2
button 3
image "myimage.jpg"
menu button "Edited"
static text "myimage.jpg"
looks like the path you need is inside:
application "Preview"
standard window "myfile.jpg" (window 1)
edit toolbar (tool bar 2)
button (button 5)
popover (pop over 1)
color well (color well 1)
Unfortunately (for me) my AppleScript editing ability is not good enough to get this to work. I tried tinkering with various parts of the original AppleScript, changing toolbar to tool bar 2 etc but there are too many variable ways to edit the script for me to get it to work...
I did find one interesting thing with @Tom's original AppleScript - to get it to work on my UK Mac I had to change "Border color" to "Border colour". Here is my altered UK version for anyone in the UK who might find it useful.
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
Wow @Tom that is incredible. I have been trying to find an efficient way to do this for at least two years!
I have a Keyboard Maestro Macro that puts a date "stamp" on my paid invoices and I like it to be in red. But for other uses of Preview's Markup Text I want black. So, I was forever having to go through those pop up panels to change from one to the other.
Thank you so much! And to @hello too for suggesting how to find the names of these panels.
...Would there be a way to set font size too? I really must teach myself AppleScript as it seems such a good way of getting at stuff that isn't included in Menus.
tell application id "com.stairways.keyboardmaestro.engine"
set inst to system attribute "KMINSTANCE"
set textSize to (getvariable "Local Text Size" 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 text field
set its value to textSize
confirm
end tell
end tell
end tell
end tell
end tell
end tell
end tell
That group of three Macros (Border Colour/Text Colour/Text Size) is going to be so useful for me and my use of Preview. And I'm sure others here will find them really useful too.