Sequential Numbering in Macro

Is there a way to add a function to a macro, so that every time the macro is used, a numeric variable is increased by 1?

For example, if a hot key macro prints type “Wall Paint Black001” the next time I use the hot key, can it print “Wall Paint Black002”?

Thanks in advance for your help!

No function is required. All you need is:

All KM Variables (KM Wiki) persist after the macro completes (actually after the Action is executed), and are available for use in the next run of the macro and/or other macros. IOW, KM Variables are permanently stored in you Mac until/if you specifically delete them.

Here's a complete macro as an example:

MACRO:   Sequential Number of Variables

VER: 1.0    2017-07-01 ~~~


Sequential Number of Variables.kmmacros (3.1 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

Please let us know if you have further questions.

1 Like

Hi JMichael,

Thank you for your help. I read up on how to use KM Variables, and am now learning how it works.

When I use the example that you sent me, I tried adding the variable "WPB__Name" to a hotkey, however when I use the hotkey, I get the same number, "WallPaint Black025, WallPaint Black025, WallPaint Black025". Is this because it is intended for a script, rather than a hotkey?


Well, that is because that is exactly what you have written your macro to do. :smile:

Try this:

Add your Action

as the last Action of my macro, and assign your hotkey to my macro.

It worked! Thank you so much!

All I need now is to loop, Is there an easy way to loop two macros? I will search the forum.

Start Loop
’Macro 1’
End Loop

A post was split to a new topic: How Do I use Loops with Multiple Macros?

I have started a new topic with your question: