Add Punctuation to the End of Highlighted Text (If None Exists)

Hi All,

I'm looking for a macro that will check if a highlighted line or (last sentence of a) paragraph of text ends with a period, and if none exists, to add one. I've searched the forums for a macro that will do this, but am not having any luck.

I'm guessing the solution involves regular expressions and/or JavaScript, but I'm a newbie at both so I have no idea how to create this myself. Any tips would be much appreciated!!

Hey @Ser_Dirtnap,

This one doesn't require anything fancy – just a good understanding of Keyboard Maestro's capabilities.

Keep on plugging away, and you'll improve your specific knowledge and your ability to find what you need in the Keyboard Maestro Editor, on the KM forum and in the KM Wiki.

Take a peek at this post for some hints about finding help:

Frustrated w KM and KM Forum - Maybe I'm Missing Something - #6 by ccstone

Here's an example of what you're trying to do:

Check for Punctuation Character v1.00.kmmacros (6.4 KB)


Keyboard Maestro Export


Thank you, @ccstone!

I was actually reading that post when I saw your reply!

It's been really fun learning about this stuff. I'm still very new to all of it, but I feel like I'm picking up a bit more every time I work with these examples.

The macro you posted was super helpful—the action that I needed was the one below.

I've been using the "Trim spaces and convert to sentence case" macro that I found at this topic and modifying it as a text cleaner. I tweaked the action below to look for punctuation and add a period at the end of the text if needed. So far it's working great!

Screenshot 2022-12-22 at 1.47.59 PM

I really appreciate you taking the time to respond. I feel like my understanding of how to work with variables just leveled up!

Fun indeed...  :sunglasses:

You get out of Keyboard Maestro what you put into it.

It took me no time at all to start getting simple things done, but it took me a couple of years of fairly dedicated work to gain real proficiency.

It's been nearly 20 years now.

Oh, one more thing.

If you're going to use the text from the clipboard a bunch of times you might as well save it to a variable first.