Macro to change style or color of text before I type it?

I'm new to KM. Is there a simple macro to change the style or color of text before I type the next word in a sentence?

Hi @luiz, welcome to the KM Forum.

Here is my solution for writing with different text colors in Apple Mail:

2020_09_05_Support_3

The KM palette is called with the text string trigger "yy" and the text color is changed with the first letter of the macro (R = Red).
If you want to change back to the system font color (here Black), you only have to press the stage key.

Here is the macro for this:

Text Color Mail Macros <F76A 200905T231442>.kmmacros (65,9 KB)

You can make further changes to the font, size etc. in the actions marked with the red arrow:

2 Likes

There is not a "canned" macro to do so, but you could easily create one for your specific needs.

If this is for a specific app, then you could use the Select or Show a Menu Item action to set the color and/or other style. Unfortunately, some apps, like TextEdit do not lend themselves to this type of automation.

So here's a simple, one-action Macro:

image

It will insert a SPACE that is formatted as you like, and then any following characters you type will use this format.

Example

Starting with this TextEdit document:
2020-09-05_17-06-17

after you finish typing "all", then trigger the macro
and type "good men"

2020-09-05_17-06-55

You can format the text in the "Insert Styled Text" Action using the KM menu Edit > Format:

image

2 Likes

Hi appleianer:

Thanks for your reply and for the macro.

I’m trying it out, but having trouble making it work.

I brought the macro into KM and typed “yy” as the string, but nothing happened. Then I saw that the string is actually “jj”, so I typed that but nothing happened again. What am I missing?

Danke!

Luiz

Hi JMichaelTX, thank you for your reply and for your macro. I tried it out, and it worked quite well to make the text red (for instance). The only thing is that when I applied the macro on a TextEdit document and the new red text appeared, it was in a different font size than the previous text in the document. I was trying it out on Text Edit. The same thing happened when I tried it in Mail, except that in this case it also went to the next line as opposed to continuing writing on the same line. Any suggestions?

Hello @luiz, you tried it in Apple Mail? If you enter "jj" in Apple Mail no palette appears?
Please excuse my mistake in my post above. The translation into English would accidentally use "yy" as Text Sting :pensive:

Hi appleianer, yes, I just tried again typing "jj" in Apple Mail, nothing happens. Could it be that you're using a German keyboard and the "jj" is another letter? Also, after I bring the macro into KM, do I have to do anything else to activate it?

That can be. Please check if the macro group is activated @luiz:

2020_09_06_Support_1

Please replace the Text Stone Trigger with the text you want, so that you can select the desired text color with the starting letter after opening the palette.

Ok, that was the initial problem. Thanks for pointing that out. I activated the macro group now, and when I type "jj", the color palette appears. Do I actually have to choose the color red in the palette with the arrow to make the text red? I thought the macro would run automatically after I typed "jj"....

@luiz with "jj" you call up the palette and then you select your text color with the first letter (R = Red etc.). The text color changes automatically back to the system color when you press the escape key.

@appleianer It works now, thanks!!!
One last issue: when I write text on a new email on Mail I have the font size set up automatically to Helvetica 28, because my vision isn't so good anymore. When I use the macro by typing "jj" and then choose m for magenta, for instance, the new word in magenta is still Helvetica 28, and that's good. However, if I type "jj" and choose r for read, or b for black, the new word appears in Helvetica 12. The same thing happen if I type escape to go back to black. I wonder why. I'd prefer if it would still be size 28 like when I choose m for magenta. Very strange... Do you have any idea why that's happening?

I am glad to hear @luiz that it works now.

Please change the font size in the macros (red arrow) from 12 to 28:

Actually, instead of setting the font size to 28, I left now the font size in the macro UNselected in both places, and it is working now.
Thank you again, you were very helpful, and I think I understand now a little more how KM works!
Have a great Sunday!

1 Like

Ditto @luiz and it is good to know that it works for you. Not that the day would end like this... :wink:

Laptop

To prevent this from happening... the KM Forum is the best I know.

1 Like

For some reason, the second part of @appleianer's macro does not work for me.
It works in changing the font to colors other than black. but when I hit Escape, it pastes the black "q" character, but when it is deleted, the color is restored to the non-black color.

@JMichaelTX's simple macro works.

After pasting, however, it adds a line break after the styled "space". Since I usually run the macro after space, I added a "Delete" action both before and after the styled "space". It works great so far.
image

1 Like

I don't get the extra RETURN that you are seeing, but IAC I'm glad you were able to adapt my macro to suit your needs.

Yeah, that happened with me sometimes with the Escape key on @appleianer's macro, but somehow it now works fine most of the time. I haven't been able to figure out why.

The problem I have with @JMichaelTX's macro is that besides changing the color to red, it also makes the new text a specific font size (13). Since I write with a different font size (much bigger due to my poor eyesight), I don't want the macro to apply a different font size. I was able to keep the same font size on @appleianer's macro by deselecting the font size box to keep it unchanged, but I don't think I can do that on @JMichaelTX's macro

OK, I have a new version which should fix that.

Example Output

Demo-Set-Font-Style-in-KM-Very-Short-AN

Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

Please let us know if it meets your needs.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Change to Styled Text Starting with Current Style [Example]

-~~~ VER: 2.0    2020-09-07 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Change to Styled Text Starting with Current Style [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Change to Styled Text Starting with Current Style

==HOW TO USE==

  1. First, make sure you have followed instructions in the Macro Setup below.
  2. In your source document (TextEdit for example) set your normal style and type whatever.
  3. End your typing with a SPACE character
  4. Trigger this macro.
  5. Now Type using the new style from KM
  6. To return to original style,press the Right Arrow Key.

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      .
      Make These Changes to this Macro
  1. Assign a Trigger to this macro.
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
  3. ENABLE this Macro, and the Macro Group it is in.
    .
  • REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
    (all shown in the magenta color)
    • Apply Style to CB: CHANGE to the Style You Want

REQUIRES:

  1. KM 9.0+ (may work in KM 8.2+ in some cases)
  2. macOS 10.11.6 (El Capitan)+

TAGS: @Clipboard @Style @Font

1 Like

I can confirm it works great. Thanks a lot, @JMichaelTX.

To use the "right arrow" key to return to previous color, we'd better type the right arrow key without typing space, otherwise, there will be two spaces. This method had advantage of returning to whatever the previous color was before the switch.

If we are used to type "space" after every word, @appleianer's method of using "Escape" to return to "black" color might be a good option. This method, strictly speaking, does not return to the "previous color", it returns to whatever color is set by user (in most cases, it would be "black").

Just a tip: If we want to implement @appleianer's method of using "Escape" to return to "black" color, we can simply use "execute a macro" action, so that we don't need to repeat the process again for every different color.

Ok. I spoke too soon.
I get very strange behaviors in different apps.

In Scrivener, where I tested initially, it works flawlessly.
In Notes (came with MacOS) and Nisus Writer Pro, it does not work at all (not changing text color).
In Mail (came with MacOS) and Spark (email client), it works but adds a return to it, I need to add a Delete keystroke.
In "Word", it does not work either, but the cursor goes a step back, as if I had simply clicked the left arrow.

This is very weird! :rofl: