I would like to create a template for new macros created according to macro group

After noticing quite a few times the ways you guys name your macros, I really started to like putting in the scopes of where the macro is active into the names of the macros. Thank to Dan's very handy spotlight like searches, creating, editing and all together using km editor is becoming more and more enjoyable.

However this brings me to a problem, that I would then need to type every time the prefix for all my new macros like so :

It would be really nice if km editor would add templates for newly created macros in some group. Like for example I can write click on a macro group, select the template I want and then newly created macros would start like so :

I hope such a thing would be possible to do and not too difficult to implement and I hope am I not alone in wanting this.

Thank you.

I don't know about the right-click part, but since several people (@DanThomas, @ccstone) have written scripts to get the current Macro Group, you could trigger this template selection by clicking on the Macro Group (or any Macro in the Group), and the pressing the hotkey you assign.

I think building this macro is of moderate difficulty, but would be time-consuming. I think you could do it. :smile:

The key section of the macro would be a "Switch" action, where you have a Switch element for each Macro Group. Then, in that element, you can construct the template(s) you want, and prompt the user to select one.

Once you have the template, it could be as easy as create a new macro (use the KM Action "Select menu"), and type the name template you have chosen.

Give it a shot. If you have issues/questions, post your current macro, and I'm sure you'll get lots of help.

Good luck.

1 Like

I will try make it but it does seem quite challenging. Thank you for giving me a starter.

1 Like

That's how we all grow, when we have to stretch our knowledge to do something new. :smile: But no worries, I'll be glad to help if you really get stuck.

I'll share an example, using myself. I have observed for over a year the power of using XPaths to find and do stuff in web pages. But it was such a new technology, a new language to me, that I couldn't even seem to get started.

A couple of days ago, I had an urgent task to get done, in which XPath seemed the logical answer. So, I rolled my sleeves, opened the target web page in Chrome, and used the Chrome "Inspect" tool to show the HTML and the JavaScript console.

Long story short, after a few hours of trial and error, the light bulb finally came on, and I made my first use of XPath.

Turns out it is not that hard, once you "get it". :wink:
Now, it seems easy.

Well, I hope I haven't bored you with my little story, but have given you some inspiration to venture out on your own with this macro.

Why not just duplicate an existing macro? Or in this case, perhaps even create your template macro, and then duplicate that? If you don’t want it showing up in a palette or whatever, you could just disable it, so then your action would be:

  • Select template macro
  • Duplicate
  • Delete " copy"
  • Enable (optionally)


  • Select template macro
  • Copy
  • Paste
  • Enable (optionally)

Unless you’re creating dozens of macros, that would seem reasonably efficient.

This seems to take longer and more hassle than just typing manually my macro template with each macro made. Having an empty template macro that I will need to copy and then use is still quite undesirable, especially if the macro group is big (you would need to find the template macro).

Perhaps if I can automate the whole duplicate template macro and use that and bind this action to ⌘ + N then I have solved my problem.

@DanThomas, in your vast arsenal of macro tools, do you by chance have a script that will copy a macro (given its UUID), and create a new macro from it in the same macro group?

If so, that could be just what @nikivi needs.

1 Like

@peternlewis I would really love to have this feature included natively with km. I would love to have your thoughts on it, would it be possible to implement? I would really really love to have it as right now I spend quite a bit of time modifying my prefixes with macros and I really dislike this.

Thank you and I really hope you will consider adding something like this.

How about you create a template macro for a group and leave it there (disabled if you don’t want it visible on a palette), then just use Cmd+D to duplicate it each time you want to create a new macro?

…and sorry I forgot to reply to JM’s post earlier. I got distracted. :slight_smile:

Yeah, you would need to go to the template group, cmd + d and then go to the template group you want to create your new macro every time I want to create your macro. :frowning:

I really wish there was a better solution and better way that was builtin into the editor.

OK, I can put together something to do just what you’re asking for. I’ll post something later today.

1 Like

OK, I need to address this again, because everything I think of doing can actually be done easily without my help.

Here’s what I’m suggesting: In each Group, have a template macro. So all you need to do is select the template macro in that group, and duplicate it. Done.

If that doesn’t work for you, can you give some actual examples of why this won’t work? Because if I understand what the issue is, I can probably provide something.


So there’s no way to do it other than manually going to the group, duplicate it, go back and pasting it?

This is a shame. :frowning:

No, that’s more steps than is necessary.


  • Do this one time per group:
  • Create your template macro in the group.

When you want to create a new macro using the template:

  1. Select the Template Macro.
  2. Type Cmd+D.

Done. Rename the duplicated macro however you want, change it however you want, whatever.

All it took to create a new macro from the template was one click and one button press.

Oh I see now. I want to minimise mouse clicks as much as possible as I find it very inefficient. This solution is still quite inferior to solve the problem I have but I suppose there is no other way around this unless @peternlewis does decide to include such functionality but that may be unlikely since I am probably the only one wanting this.

It would great to have it though.

Get in line. I have a whole list of things that I want Peter to add, but I know I'm probably the only one who wants them. :slight_smile:

Hey Nikita,

That depends entirely upon how ingenious you are.  :sunglasses:

Here's something to get you started:

Get Group Name.kmmacros (4.7 KB)

This is a little clunky, but it works whether or not there's a macro selected in the macro pane of the editor.

All you have to do now is save some templates to variables, named-clipboards, or files on-disk.

Then you detect the selected group and paste in the desired template.


1 Like

If you just want to create a template macro, why not just copy a macro in to a Named Clipboard, and then have a macro that pastes from that Named Clipboard?

Thank you so much ccstone. This works beautifully.

Here is the macro that solved it. Again, thank you @ccstone

###MACRO:   km: create new macro from template

~~~ VER: 1.0    2016-09-11 ~~~

km- create new macro from template.kmmacros (5.0 KB)