Docs

RunMacro Documentation

Create your first robot, then go further as needed.

Clear step-by-step guides to create, run, and improve robots for repetitive computer work.

Docs Flow Break Loop
⏹️ Flow

Break out of an active loop immediately in RunMacro

The Break command instantly exits the active enclosing loop (While, For Each, Loop) and advances execution past End Loop.

Prerequisites#

  • Break must be positioned inside a valid loop block (Loop, While, or For Each).
  • Typically enclosed in an IF condition to determine the appropriate exit timing.

Supported modes#

  • Desktop Mode
  • Browser Mode
  • RunMacro Runner

What it does#

The Break Loop command immediately terminates the innermost enclosing loop block (supporting Loop N times, While, or For Each). Upon execution, all remaining actions in the loop are bypassed and control transfers directly to the first command past the matching End Loop (or legacy End If). It provides a clean, structured mechanism for early loop termination without convoluted Goto labels.

Screenshots & video#

RunMacro Break Loop command configuration dialog showing parameter fields
Configuration dialog and parameter fields for the Break Loop command in RunMacro.

When to use it#

  • Searching collections: exiting immediately once a target item, image, or value is located.
  • Encountering critical errors during an iteration where halting the whole batch is required for safety.
  • Satisfying an early completion condition inside complex While or For Each loops.

When not to use it#

  • Skipping only the current cycle to start the next iteration (use Continue instead).
  • Returning from a sub-macro back to the parent macro (use Goto Parent File).

Configuration steps#

  1. Identify the condition check point inside the active loop body.
  2. Place a conditional check (such as an IF or Find Image command).
  3. Inside the condition true branch, insert Control Flow › Break Loop.
  4. Save workflow. When the condition evaluates to true, Break jumps execution past the loop boundary.

Every option explained#

Innermost Loop Targeting#

Automatically targets and exits the immediate enclosing loop level with zero manual parameter setup.

Expected result#

The loop halts immediately at the Break call and execution continues with the command following the loop block.

Real example#

Example: Search list items and break on match#

  1. For Each loop iterating over file rows.
  2. IF check: if {item} == "TARGET_ID".
  3. Inside IF: insert Break Loop command.
  4. After End Loop: display success notification that target was found.

Limitations and failure cases#

  • Break only affects the local synchronous execution thread; background threads cannot be halted via Break.
  • Corrupted loop hierarchies missing an End Loop boundary will prevent the runner from locating the exit target safely.

Tips & common mistakes#

In nested loops, Break only exits the innermost enclosing loop; outer parent loops remain unaffected.
Only place Break commands inside an active loop block; using Break outside loops is flagged as an invalid structure error.

Verification details#

  • commands/control_flow.py
RunMacro robot

Robots do the work. Your time is yours.

Create a robot in minutes, no coding needed. Reliable execution, remote management, transparent costs — and you always stay in control.