Apple Pages—change font color

Hello!
macOS Sequoia 15.5
Pages 14.4
Keyboard Maestro 11.0.4

My goal is to build a macro that changes the color of currently selected text in Pages’ front window.

How can I build the macro to interact with macOS' text color picker?

I built a macro that includes a move and click mouse action to an image—screen capture of the color picker's Maraschino crayon.

The macro functions without moving the mouse.

I've changed the action's fuzziness setting and the "in" menu's setting without any luck.

How can I fix this macro so that it functions successfully?

Why are you choosing to use the complicated "color picker" if there's a simpler solution using AppleScript? Pages does have AppleScript support. I got very close to solving your problem with AppleScript, but since I was only close, I will leave it to someone more adept with AppleScript to provide a correct solution. (It's possible that a solution may require ^X to remove the selected text, then manipulate the color of the clipboard, then paste the result back with ^V. This will likely cancel the selection, which may not be what you want.)

Since you didn't upload your macro, (you just uploaded a screenshot) I couldn't see the settings on your Move and Click Mouse action. I'm going to guess that you checked the item "Restore Mouse Location". If I'm right, then try unchecking that as a test. If that fixes the problem, then that means the problem is with Pages. This problem can be fixed by saving the mouse position, performing the click, and then moving the mouse back to the original position using a KM action. I encounter this problem frequently with apps.

1 Like

As @Airy mentioned, AppleScript would offer a simpler solution, especially for apps that have strong AppleScript support.

Looking at the image you used in your "mouse click to an image" example, it seems like it was edited in another app. This often changes the image in a way that prevents it from matching anything currently on your screen.
image

Good catch. I didn't notice that. He could change the image by just searching for the colour underneath the brown area. I'm sure that would be fine. But the way he's doing it won't work.

I.e., he should change the image to something like this: (which is perfectly rectangular)

image

1 Like

Hi Airy and JuanWayri,
Thank you for your postings.
Why am I using the color picker? Because AppleScript is not working on my end. I have posted to MacScripter about my script's problem (even though the term "selection" is included in Pages' AppleScript dictionary, it is not validating in my script).
Even if my script did validate, I anticipate that it will not change the font's color. My understanding is that Pages prioritizes paragraph style over character style in AppleScript scripting.
Yes, I am aware that using the color picker is kludgy. But that's my alternative to getting my AppleScript script to function successfully.
Yes, I have done the routine of copying to the clipboard and then pasting back. That routine fails in Pages (the selected text retains its original color), but the pasted text has the new color when pasted in a different app (I used Bean to test this).
No I did not check Restore Mouse Location. I now have tested your suggestion by checking and unchecking the Restore item. It makes no difference, the selected text's color remained the same.
Thanks for the suggestion to use a different image. I copied a rectangular portion of the Maraschino crayon and replaced my original (edited) image with the rectangle. Same outcome—the mouse now moves to the crayon but evidently does not click it since the selected text retained its original (black) color.
My test macro is attached (FWIW).
:thinking:
z red text test.kmmacros (15.3 KB)

Try splitting the move-and-click into a move to image, a 0.1s pause, and a click at current location:

(I had to reduce the fuzz and set image detection to "Best" rather than "Unique" to get a good match.)

Hi Nige_S,

Thank you for your helpful posting…yesss!

:slightly_smiling_face: