Macros I Use All the Time

Here's some macros I use literally all the time, and I think they'd be of use to just about everyone on this forum.[1]

Paste by Name

Thanks to @peternlewis for this one. I've used this over 3,500 times[2]. It's just one action long:

image

Available in all applications, and I've assigned it to ⌃⇧V. Try it. I guarantee you'll use it constantly.

Insert %Variable%(clipboard)%

Let's say you have a variable named "Local_Result" on the clipboard. Press the hotkey, and it gets pasted in as %Variable%Local_Result%. I've used this over 2,500 times. Again, it's just one action long:

image

%%Variable%%%CurrentClipboard%%%

Available in KM, assigned to hotkey ⌃V.

Cut Selection and Insert "%Variable%"

This is like the previous one, except you've already typed in your variable name. Select the variable name and trigger this macro, and it replaces it with %Variable%(selection)%. Just three actions long:

image

Available in KM, assigned to hotkey ⌃X.


EDIT 8/25:

I use these literally ALL the time:

And of course

and last but certainly NOT least:


  1. I may have posted something like this before, but I suffer from CRS syndrome. ↩︎

  2. KM stores usage counts in the file Keyboard Maestro Macro Stats.plist. I'll be posting a utility for looking at these counts at some point in the future. ↩︎

6 Likes

Thanks for creating this topic, @DanThomas. It's incredible how much power there can be with very simple macros.

Another action that comes to mind is Trigger Macro by Name:

Keyboard Maestro Export

Yes, three big cheers for Paste by Name ! :beers::beers::beers:


For those that might be interested, I've shared a generalized macro named Augment or Transform Text that so happens to cover the variable conversions. Of all the macros that I've created, I'm sure it's on my top five used list.

1 Like

...had completely passed me by -- I really don't make enough use of the KM's Clipboard History. So thanks me giving me a push, @DanThomas.

And, perhaps because I don't use the Clipboard enough, I've got a typed string triggered macro for KM variables:

So ;, an optional v for when it's a text token, a single letter to signify scope, ; for "end of typed string". The macro inserts the boilerplate and uses the %|% token to set the insertion point, ready for the variable's name to be typed.

Typed text: ;vl;result
Inserted text: %Variable%Local_result%

KM Variable.kmmacros (5.7 KB)

Image

4 Likes

@alltiagocom turned me onto the power of this as a replacement for the Conflict Palette (and I really owe him a beer for it!).

I had a bunch of "application openers", all with the same hot key trigger, and was typing to select which to run. The problem was that if I wanted "Outlook" or "Outback" from

image

...I'd automatically type the o, then the u... and the Palette would disappear without firing anything because the u wasn't the next differentiating character.

But using "Trigger Macro by Name", pointed at the Group of macros, I just type normally until it's time to hit the Return key:

3 Likes

I think that's easy to do, because it takes a little effort to get up to speed on it. It may also depend on your typing skills, and memory. I worked with a guy who typed fast and rarely made mistakes, so for him it was often easier to just type things again. Not so much for me, though. Mistakes-r-us (me).

That's too much for me to remember, although I'm sure it makes complete sense to you! I've got a lot of similar-ish stuff I use in VS Code, but I put most of them in a palette because I couldn't remember them otherwise.

2 Likes

A couple of thoughts...

FWIW, I use Alfred's clipboard history and never felt the need to try anything else. Any benefit to switching to KM's version?

Do you find that tokenizing variables using Insert Text by Typing fails quite often, due to KM updating its state?

I use Trigger Macro by Name to show me all macros for the current app, and if I hold a modifier when I trigger it, it shows me all the globally available macros instead. It's really nice and simple like that.

3 Likes

I highly doubt that - if you are finding an action is failing, I suggest you post it because there is almost certainly a reason for the issue.

You can also do things like use the Log action to see the results of token processing.

I can't find the thread right now, but I could have sworn I got the info (Insert Text by Typing occasionally failing inside the Editor due to it updating its state) from a comment you made yourself. I must have been mistaken.

I've been using two actions:

...but I see Dan is using just one:

Perhaps this will be more reliable.

P.S. Sorry @DanThomas, didn't mean to derail.

1 Like

I always add letter codes before the macro name if it is to appear in a conflict palette, so using your example, that would be:

  • NN NetNewsWire
  • OB Outback
  • OL Outlook
  • PP Powerpoint

That way, if I type a wrong second character, it's not because I've incorrectly guessed it. (Yes, the second character is often redundant but always present, for consistency and presentation).

It promises to be a more elegant approach than using a conflict palette, but two aspects make it a disappointing alternative.

  1. It seems that the information panel on the right of the prompt cannot be hidden (have I missed something?). Therefore, when the prompt appears in the middle of the screen, my visual focus is not on the list of macros, but on this area:

ccc2.png

Yes, I can move my eyes to the left each time, but the refocussing does significantly break the "flow" of interacting.

Also, I simply do not need the distraction of the information given by the panel, nor its big fuzzy icons.

  1. A conflict palette will display a list of "conflictingly named" active macros whether they are in the current group or not. Trigger macro by name can be set to show macros from the current group but to include otherwise active macros in the prompt requires specifically adding them (by copying the macros to the group or by creating new macros containing an Execute a macro action).
1 Like

OK, I wrote a macro to eliminate the extra panel.

Execute Macro by Name.v0.1.kmmacros.zip (5.0 KB)

image

Right now, it only includes "enabled" macros, but I have full control over what's returned, because I generate the list in JXA. So I can add whatever options we want.

Click for image of macro

image

I added the option to use a regular expression to either filter out, or only include macros whose names match the regex. Right now, I set it to filter out my palette separator macros.

Let me know what you think.

2 Likes

That's very cool and something I've seen requested before. :clap:t3::clap:t3:

I if I hit §, I see all macros for the current app.

If I hit ⌥§, I see all other macros.

I do that using smart groups like this:

Could your macro be adapted to do something similar?

I noticed it's not quite as snappy as the native action. This is me being really nitpicky, but do you think it might be better to grab the macro list (as a global variable) whenever the KM Editor is closed? I know that would mean that you wouldn't be able to trigger a brand new macro until you closed the Editor, but it would probably mean your macro would run quicker in day-to-day use.

1 Like

I suppose anything's possible.

I'm probably not going to put much work into this, for now.

1 Like

Fair enough. As I said, was being a nitpicker. You've solved a problem very nicely there.

1 Like

Thank you, that's very interesting and I'll study the macro for my education.

Sure... Please note that I am not asking for refinements to be implemented, and this is just by way of requested feedback.

Advantages over the built-in action:

  • The panel is indeed gone. (Since no-one has corrected me about it being impossible to remove in the standard action, I shall post a suggestion about this elsewhere).

Disadvantages at present, compared to the KM action:

  • As you mention, currently the macro lacks fine tuning of which macros are included.
  • The macros are not listed.
  • Leading numbers (used for setting the order) are not hidden, e.g. a macro called "3)Do something" will not appear as "Do something".

But yes, it works smoothly and is a good proof of concept.

I wouldn't, no, but thanks again and I look forward to studying the macro.

1 Like

I have now found a post from @peternlewis from October 2023:
"There is no way to affect the appearance of the palette."

Sorry to have returned to something that had previously been covered. I did search but perhaps "macro" being spelled as "makro" in the title hid the thread from me... Well, it made a change from "marco"! I've corrected the title in order to, I hope, make that thread more findable for others.

No worries from me. I've posted on plenty of topics I posted on previously and totally forgot, so I can't criticize anyone else for their lack of searching ability!

I take pride in my searching ability, I just didn't expect to have to search for "macro", "marco" and "makro" – but now I know! :laughing:

1 Like

For whatever weird reason, my brain can handle that in some situations, but not others. So I've an Outlook Conflict Palette with n as the distinguisher for my Inbox window, d for the team's calendar window, and so on.

But I guess I think of apps and bookmarks by name, and it's less mental load to type outl or bofh than to "translate" the thing I want to a "shortcode".

Ain't that the joy of KM? You can go your own way...

I'm too focused on hunting and pecking the keyboard to notice that :wink:

That's totally true, and also, I was just this minute listening to "Go Your Own Way" by Fleetwood Mac. :smile:

Yeah, me too. And I've gotten worse at it with old age. Have you ever stared at the keyboard and wondered where a certain key went? "Where the hell is the $ key?" :joy:

3 Likes

Agreed, but try looking for £ or hash sign on the wrong type of keyboard.....

PS Just for the old-timers here...
Ascii and Extended Ascii was fine until IBM invented EBCDIC when you got zero, positive zero and negative zero together with a different sort sequence for letters and numbers


Zero in ebcdic

In EBCDIC (Extended Binary Coded Decimal Interchange Code), the character for zero is represented differently depending on its sign.

  • Positive zero: 0000 or 000 (without the curly braces) denote a positive zero.
  • Negative zero: 000{ (with a curly brace) denotes a negative zero.

When packing decimal numbers in EBCDIC, the left nibble of the last character is often overlayed with 0xF to make it a readable EBCDIC character digit, resulting in the zoned decimal format.