I use the repeat action function in my macros quite a bit and have found that I need to define the amount of repeat times based on the outcome of a certain function. Currently, the repeat function only allows to predefine a static amount of repeat times and does not work when a variable is inserted.
Maybe it is because you variable has not been declared.
Try with the macro below.
Repeat based on user input Macro (v10.2)
Repeat based on user input.kmmacros (2.7 KB)
That's not true.
Try this macro:
Download Macro(s): Test Repeat With Variable.kmmacros (2.4 KB)
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
- macOS 10.14.6
- Keyboard Maestro v10.2
You should note that the field that specifies the number of repeats is a calculation field and not a token field. If you don't know the difference look them up in the KM wiki.
Jimmy and tiffle, thank you. This is so simple, yet I missed it. I was using the regular "Repeat" action instead of this. Although I was not able to find it in the Control Flow category. Where did you find this?
There is only one "Repeat" action. The trick you may have missed is that, like many "Calculation" edit boxes, it starts with a small box and a spinner for changing the number but automatically expands when you type or paste in a calculation or variable.
And, like most actions, its name in the macro reflects any parameters you set. So what is "Repeat" in the Action List becomes "Repeat Actions 3 Times" if you set the number to 3, or "Repeat Local_count - 1 Times" if using a variable and calculation, etc.
This is really handy when looking at a macro to see what each action does at a glance, but can be a bit tricky when trying to match a macro's action to the original in the Action List... When in doubt, try typing a "verb" from the action's name into the Action List search box with the "All Actions" Group selected -- that'll usually help.
For example, you won't find this easily by looking:
...but type "zoom' in the search box and:
Actually I did try inserting the variable there, but my error was that I inserted it like this instead:
Thank you for pointing this out!