Integer Variables in Mini Mouse Macro

Table of Contents
  1. Introduction
  2. Defining Integer Variables
    1. Basic assignment
    2. Action math formats
  3. Integer Expressions
    1. Supported operators
    2. Examples
    3. Where expressions are used
  4. Numeric Behavior
    1. Expressions in loops and repeated actions
  5. Integer Comparisons in IF Statements
    1. Supported comparison operators
    2. Examples
  6. Random Integer Values
    1. Examples
  7. Best Practices
  8. Related Docs

Introduction

Integer variables store whole-number results that you can reuse throughout a macro. They are commonly used for counters, coordinates, loop state, random values, and calculations that drive later actions.

You can use built-in names such as %INTEGER% and %INTEGER1%, or assign your own descriptive names such as %Count%, %OffsetX%, or %RetryNumber%.


Defining Integer Variables

Use RUN ACTION | DEFINE INTEGER VARIABLE to assign or update an integer variable.

Basic assignment

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::100
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %LoopCounter%::0
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %ProductID%::12345

These examples assign 100, 0, and 12345 to three different integer variables.

Action math formats

Mini Mouse Macro supports shorthand action formats such as:

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::10
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::+100
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::-5
4 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::*2
5 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::MAX7

These formats are useful for direct one-step changes to an integer variable.


Integer Expressions

RUN ACTION | DEFINE INTEGER VARIABLE also supports full arithmetic expressions. This is useful when you want to calculate a value using variables, parentheses, and mixed operators.

Supported operators

  • +
  • -
  • *
  • /
  • %
  • parentheses
  • unary +
  • unary -

Use the operators listed above when writing a full expression. Shorthand forms such as +100, -5, *2, and MAX7 are also supported as shown earlier in this page.

Examples

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %DX%::%EX%-%SX%
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %MX%::%SX%+(%DX%*%I%/20)
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %Value%::((15+5)*3)/2
4 | RUN ACTION | DEFINE INTEGER VARIABLE | %Signed%::(-5)+2

You can also assign a variable directly:

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %CurrentX%::%MOUSE_X%

Where expressions are used

The expression examples in this section apply when you use:

  • RUN ACTION | DEFINE INTEGER VARIABLE

Other parts of Mini Mouse Macro use their own formats. For example:

  • IF | INTEGER VARIABLE | ... comparison behavior
  • DEFINE DECIMAL VARIABLE
  • non-action variable assignment paths

Numeric Behavior

When you use an arithmetic expression, Mini Mouse Macro keeps decimal precision during the calculation and converts the result back to an integer at the end.

That means:

  • intermediate division is not truncated at each step
  • nested expressions can preserve fractional intermediate values
  • the final value is rounded to the nearest integer using .NET midpoint-to-even rounding

For example:

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Result%::(5/2)*2

This evaluates as decimal math first, so the final result is 5, not 4.

Expressions in loops and repeated actions

If the same DEFINE INTEGER VARIABLE expression runs repeatedly, such as inside a loop, Mini Mouse Macro continues to use the current values of your variables each time the action runs.


Integer Comparisons in IF Statements

Integer variables are also used in conditional logic.

Supported comparison operators

  • =
  • !=
  • >
  • >=
  • <
  • <=
  • IS EVEN
  • IS ODD

Examples

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Counter%::5
2 | IF | INTEGER VARIABLE | %Counter% | = | 5 | MESSAGE PROMPT | Counter is 5::Match
3 | IF | INTEGER VARIABLE | %Counter% | IS ODD | MESSAGE PROMPT | Counter is odd::Info
4 | IF | INTEGER VARIABLE | %Counter% | > | 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %Counter%::%Counter%+10

These comparisons use their own condition format.


Random Integer Values

Mini Mouse Macro also exposes random integer tokens that can be assigned into integer variables.

Examples

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %RandomValue%::%RANDOM%
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %DiceRoll%::%RANDOM_1-6%
3 | RUN ACTION | WAIT SECONDS | %RANDOM_5-15%
  • %RANDOM% returns a random integer.
  • %RANDOM_x-y% returns a random integer in the inclusive range x to y.

Best Practices

  • Use descriptive variable names when the value has a clear purpose.
  • Use full expressions when you want multi-step calculations to be easy to read.
  • Use shorthand action formats when you want a quick one-step change.
  • Guard divisors in your macro logic when zero is possible.
  • Use the formats on this page with RUN ACTION | DEFINE INTEGER VARIABLE.

Back to Top