Repeat with incremental numbers

Im trying to create a macro that I can prompt user input to set how many repeats. This much I have.

What I need inside of that loop is to have a variable that increments a press of a key (down arrow) by 1 every time it goes through the loop.

For example, I have 10 rows of folders in one folder. Every time it goes through the loop it defaults at the parent folder so I need it to:

  1. arrow right
  2. arrow down one past the PREVIOUSLY selected folder so that every time it comes back to the folder, it moves right and ONE MORE down than last time.

The outside loop will tell it how many times to come back

Hopefully that makes enough sense for some help :slight_smile:

Thanks in advance. Cheer!

Unless this is a made up example there's almost certainly a better way to do what you want -- for example, get a list of the "things" then target each thing in turn. How you do that will depend on the "things" and what you want to do to them.

But, as asked...

There is no "previously selected folder" (although I guess you could save the name and, next loop, check the selected item's name on each arrow-down, doing one more after a match is found). But you can "do one more arrow-down than last time".

Remember that your first iteration will have no arrow-downs, so the first repeat will be 0 times -- to generalise, your down-arrow repeat will be loop_number - 1 times.

And we're lazy :wink: so let's make KM do the work instead of incrementing variables ourselves.

Working through a range of numbers is just one of the many uses of the "For Each" Action, so:

Repeat with Incremental Numbers.kmmacros (4.9 KB)

Here's a demo that types into a new TextEdit document so you can see what's happening:

Repeat with Incremental Numbers -- TextEdit Demo.kmmacros (5.8 KB)

Image

Thank you! I will study this and am very grateful for your work and time :slight_smile: