Skip to main content

Repeating steps

A Repeat block runs the steps inside it more than once.

Adding a repeat​

  1. Select the step the block should follow (or no step, to add it at the end).
  2. Click If / loop and choose Repeat a number of times, Repeat while… or Repeat until….

The editor adds a repeat row and its End repeat, with the repeat row selected, so the next step you add goes inside. The steps between the two rows are the ones repeated.

1Repeat times5
2Send keys{DOWN}
3Wait50
4End repeat

How it ends​

Select the repeat row to edit it. Repeat chooses how the block ends; each choice keeps its own fields while you switch between them.

Repeat times
Repeat
A number of times
Times
5
ChoiceRow nameRuns the steps
A number of timesRepeat timesTimes times. Times is a whole number, a named constant, a $variable, or a reading from its value menu, which offers only readings that give a whole number, such as Mouse X position. It is read once when the repeat starts. A new repeat starts at 2. 0 or less runs the steps no times.
While a condition holdsRepeat whileas long as the condition is true. The condition is checked before each pass, so if it is false at the start, the steps don't run at all.
Until a condition holdsRepeat untilas long as the condition is false. The condition is checked before each pass, so if it is already true at the start, the steps don't run at all.

The condition of Repeat while and Repeat until has the same three kinds as an If: compare two values, a builtin's result, or a value or variable, with Reverse the result (not) (Conditions). Move into a variable isn't offered here: a step moved above the repeat would run only once, but the condition is checked before every pass. To use a builtin's changing result, choose A builtin's result.

Repeats can sit inside other repeats and inside If blocks.

Leaving a repeat early​

Exit the loop, from the If / loop menu, leaves the innermost repeat it is in; the action continues after that repeat's End repeat. Put it inside an If block to leave only in some cases.

Exit the loop can only be added where it would land inside a repeat. If you later move it out of every repeat, its row shows Not inside a repeat, and the action can't run until you move it back or remove it.

Stop the steps ends the whole action, from inside a repeat or anywhere else (Conditions).

A repeat that never ends​

A Repeat while whose condition never becomes false keeps the action running. Add a Wait inside such loops so they don't keep the computer busy, and make sure something inside changes the condition. The stop-all-actions hotkey (Ctrl+Shift+Alt+F9 unless you changed it on the General page) stops every running action.

The Sandbox is a safe place to try a loop: it stops a run that goes on too long.