Get Character & Word Count Macro

Another simple macro. This one is for anyone who needs to count characters (e.g. for a tweet or headline) and/or words (e.g. for writers and copywriters). It displays an alert showing the character and word count in the highlighted text when you press Control+C.

Get Character & Word Count.kmmacros (3.1 KB)


thank you, this is great! :grinning:

1 Like

This sounds very cool but for some reason for me it is not working in Big Sur and Keyboard Maestro 9.2

Update: I figured out that I had notifications for Keyboard Maestro turned off which is strange because they have always shown in the past. It works now with Display Text Briefly. I needed it turned on for Keyboard Maestro Engine and not Keyboard Maestro in notifications center.

Thanks for making this!

1 Like

Fantastic, thanks! Notifications were enabled but the imported macro group wasn't…
Now it works :grinning:

1 Like

When triggered with Option-N, this macro does not seem to do anything. Where have I gone wrong:

Word count.kmmacros (2.5 KB)

Assuming the Group the macro is in is enabled -- do you actually have copyable text selected when you run the macro? If not, the first action will fail (although you won't be notified for 10 seconds, when the action's timeout has been exceeded).

The macro is in my primary group (always active) and yes, I have selected and copied to the clipboard some text before doing Option-N

With that macro you don't copy to the clipboard -- the macro does a Copy action and puts whatever is selected onto a named clipboard, the contents of which are then put into a variable, which is then word-counted.

Select some text, then run the macro while keeping the window with the selected text frontmost.

@Nige_S Thanks but that still produces no result.

I realise "Well, it works here" doesn't help much, but... It works here.

But the macro doesn't match the description of what you are doing. Describe what you are trying to achieve and let's see if a rewrite solves the problem.

@Nige_S I want to be able to select some text and get the word count. I was trying to see where this might be failing so I created a Macro with just one action, Display Text. I cannot get it to display anything.

@ihf My original macro doesn't work for you? Have you downloaded it and tried it?

I just verified in this post that it still works on my computer (it's 310 characters and 61 words, by the way).

Does your macro work if you use the Run Macro button in KM?

If yes, the problem might be your shortcut of Opt+N.

That's correct, it does not work. I can't get Display Text to show anything

Your macro works for me right out of the box...

  • Make sure the macro is enabled and its parent macro group is enabled.
  • Change the hotkey to F1 and try again.
  • If it still does nothing then run the Interactive Help from the Keyboard Maestro Editor Help Menu.

Always make certain the macro you're building actually functions in the context it's supposed to before adding complexity.

I have the Iconaholic Loud status menu icons installed on my system, so I always know when KM fires a macro.

I never use named clipboards, unless I have a really legitimate reason to do so. All copied and pasted text goes through the system clipboard, so it's better to restrict transitory usage to it and use variables for other manipulation.

I only use named clipboards for longterm storage/reuse of formatted items such as style-text, images, KM Actions, etcetera.

Everything looks good and even when I simply click Run, it does not work. Interactive Help checked off everything. It would seem to be (of all things) the Display Text action which does not do anyting even when it is the only Action in a macro.

@ihf Please try the tests I prescribed and those @ccstone mentioned.

Also, when you're talking about macros, programming, or software in general, please be very specific about what you're doing and the actual result of your actions. "It does not work" is not very helpful and doesn't tell us what you did. We also still have no idea in what application or context you're trying to count words. Is it Microsoft Word? Gmail? BBEdit? Star Wars the Old Republic?

Can you try writing it in a step-by-step like the below?

  1. I select a paragraph of text in TextEdit
  2. I press Control-C and a window appears with the word and character count of the selected text
  3. I close the window
  4. I change the keyboard shortcut in KM to Option-N
  5. I select a paragraph of text in TextEdit
  6. I press Option-N and the window with word and character counts does not appear

So you have a macro whose only action is Display Text. What's in the main area of the Display Text action? Is a variable? If so, replace the variable with the text "Hello, world!" and run the macro. (I'm assuming the macro group is active, it's not limited to a specific application, etc. etc.)

Is it enabled?

Post the macro, so we can see.

It turns out to be Display Text Briefly is not showing anything but if I change that action to Display Text in a Window, it works fine.

It'll do that if your computer is set to Do Not Disturb

1 Like