Hi,
I am often writing a part number like “at020” and of course, at a beginning of a phrase, it gets automatically capitalized to “At020”.
Can you help me to write my first macro to remove the 1st capital letter only for a particular set of 2 first letters?

It’s probably tricky to spot because Keyboard Maestro wont see the auto correction.

You could have a Typed String trigger with a regex match of something like "\bat\d+ " (\b is a word break, and include the space at the end), and then you could do something like Option-Shift-Left Arrow, Insert Text by Pasting “%TriggerValue%”.

I don’t know if this would work for you, but there are services and KM macros that will capitalize the first word of all selected sentences. If you use the KM macro, you could exclude any words/characters you’d like.

So, the workflow is to type as normal. Then before you send, select all and run the macro.

If we tweak this a bit we can use it in KM as a Typed String trigger and get close to what you want:

(?<![.0-9[:upper:]]|\W\w)[.!?] {1,2}(?!at)[[:lower:]].

The drawback is that any “at” will not get auto-capitalized.

We could exclude the pattern at followed by a number but then we would be in trouble with things like “i am” (would become “I Am”), or with things like a preceding “1.” or “U.S.” which should not trigger the capitalization.

(Probably the macro could be optimized by running the trigger through a second regex instead of the simple filter.)

So, this is far from being perfect, but maybe it’s good enough. Just remember to manually capitalize any “at” not followed by a number

Note: Of course, you have to disable macOS’ auto-capitalization feature as shown above.