Variables and Arrays

What is the variable

Variable is a name (symbol) used in macro to stand for a value. For example, in the expression

mousecur_x + 10

Variables play an important role in Macro Expert because they enable you to create flexible macros. Rather than entering data directly into a script, you can use variables to represent the data. Then, when the macro is played, the variables are replaced with real data. This makes it possible for the same macro to process different sets of data. For example, you might want to use the action "Mouse Move" for placing the mouse pointer at a position, and the position should be determined when the macro is played. You can use a variable to instead of the coordinates value of the position. The mouse pointer will be placed at the position according to the real data in the variable while the action is executing.

Using variable in an action

The most actions support using an expression as the parameter value. You just place the variable name enclosed by the percent signs in the parameter fields. For example, %mousecur_x% tells Macro Player uses the value in the variable mousecur_x while the action executing. For more information, please refer to Expressions.

Global Variables and User Variables

In Macro Expert, there are two type variables, the Global Variables and User Variables. The global variables are built-in variables can be referenced by any macro. The values of these variables are manipulated by Macro Player, and a macro cannot alter them directly. The user variables are restricted to a single macro and its sub-macros. For more information about working with the user variables, please click here.

Naming a variable

The rules and conventions for naming user variables can be summarized as follows:

  • A variable's name can be any legal identifier - a string consists of up to 32 letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "_". The convention, however, is to always begin your variable names with a letter, not "$" or "_". Additionally, the dollar sign character, by convention, is never used at all.
  • Variable names are not case-sensitive. That is, V_ABC and v_abc will be treated as the same variable.
  • White space is not permitted.


An array is a collection that holds a fixed number of variables. These variables have the same name. Each variable in an array is called an element, and each element is accessed by its numerical index (numbering begins with 0). The numerical index is also called subscript. The following is the rules and conventions for the array:

  • The index number (subscript) begins with 0.
  • The maximum number of dimensions is limited to 3.
  • The index number must be surrounded by square brackets. For example:

    ar_abc[1], ar_abc[2], ar_abc[2,3], ar_abc[2,3,4]

  • Each element in an array can hold different data type.
  • The index number can be represented by an expression. For example:

    a_abc[2+3], ar_abc[ v_var1 * 3, 2]

Every variable can be converted to an array by the action Redefine Variable, and some actions can perform the conversion automatically.

Additional References