///
Set Variable action overview

Set Variable

The Set Variable action creates or updates variables while your macro runs. While the is used to initialize variables before the run starts, this action is used to change those values mid-execution.

For example, you could increase a counter every time a loop repeats, or update a text message based on what the macro finds on the screen.

Configuration

  • Target Variable: Pick an existing variable from the dropdown, or tap + Add New Variable to create a new one on the fly. If you create a new one, you will need to provide a New Variable Name.
  • Keep between loops: If enabled, the value you set here will persist into the next iteration of the loop. This is needed for building counters (e.g. adding 1 to a variable each time) or keeping track of state across multiple repeats. If disabled, the variable resets on the next loop.
  • Value Type: The type of data you want to store. It supports String (text), Number (numeric values), Boolean (true/false flags), and Reference (points to another variable).
  • Assignment Value: The actual value you want to assign to the variable. You can use fixed values or reference other variables by wrapping them in %% (like %myOtherVar%). You can also do math here. For example, if you want to increase a counter, you can set the Assignment Value to %myCounter% + 1, and the macro will compute the result for you.

Advanced Mode

Turn on Advanced Mode (Custom Logic) to compute the value with GScript.

Code Equivalent

// Update a variable's value setVar("myCounter", 5); // Update and permanently save a variable across different macro runs storeVar("myCounter", 5); // Use advanced logic to update a counter setVar("myCounter", getVar("myCounter") + 1);