I have an Automator Quick Action routine that changes the font of selected text to Strikethrough. Is it possible to also change the colour of the selected text to Blue please?
on run {input, parameters}
tell application "Notes" to activate
tell application "System Events"
click menu item "Strikethrough" of menu of menu item "Font" of menu "Format" of menu bar 1 of application process "Notes" of application "System Events"
end tell
return input
end run
Best Answer
To automate changing the color of selected text in Notes it can be done with UI Scripting, which you are already using to click Strikethrough on the menu.
Since you did not specify a color or which tab on the Colors window you want to work with, I'll show two examples, one for the Pencils tab and the other for the Color Palettes tab.
With the text already selected in Notes, the following example AppleScript code works for me in macOS Catalina, using US English for the Language:
For the Pencils tab:
For the Color Palettes tab, use the following block of example AppleScript code in place of the same
tell application process "Notes"
block of code in the code shown above:Note: The example AppleScript code is just that and, sans the included
try
statement in the code for the Color Palettes tab, does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g.delay 0.5
, with the value of the delay set appropriately.