Continuous Looping Through List

Any hints on how to do this?
I want to try to figure it out, but I am not sure if I am phrasing the question properly

With a list of say 10 items
Each time I call the macro I want it to give me the next item in the list

Then item2
Then item3 etc

And when it gets to the last item, start again at the top of the list

My solution would start with a global variable that increases by one with each use of the macro. Then use modulo (remainder) division by the length of the list to get a number from zero to one less than the length of the list. Unless this result is zero, use it as the list index. If the result is zero, use the length of the list as the list index.

It's easier to show an example than to describe:

RepeatingContinuousListIndex List.kmmacros (4.2 KB)

Image of macro

Update: Silly me. I forgot to mention that you have to start by setting the global variable, ContinuousListIndex in my example, to 1. You do that in the Variables tab of Keyboard Maestro's Preferences.

Hi @Mathias,

There are several ways to approach your objective. Here's one that I think is relatively easy to understand.

DOWNLOAD Macro File:
Repeat List.kmmacros (4.6 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.


Feel free to follow-up if this doesn't meet your requirements.



1 Like