Flow Conditions
This guide provides a comprehensive overview of the flow control statements, referred to as Flow Conditions within Mini Mouse Macro, that enable you to create powerful and dynamic macros.
Flow conditions are essential for building macros that can make decisions, repeat actions, and handle complex logic. By using these conditions, you can control the flow of your macros, determining which actions are executed based on various criteria, and creating loops to perform repetitive tasks efficiently. This allows you to create macros that respond intelligently to different scenarios and automate intricate workflows.
Table of Contents
Overview
Flow conditions are pivotal in creating complex macros. They allow the user to:
- Branch logic: Execute actions conditionally using
IF,IF NOT,IF THEN ELSE, andELSE. - Loop: Iterate over a set of values, files, or folders with
FORloops. - Nest Conditions: Create multi-level, interdependent logic for advanced macro control.
- Combine Actions: Use
ANDto chain multiple actions or conditions within a single line for streamlined execution. - Control Macro Execution: Incorporate
RUN ACTIONstatements for custom tasks such as file operations, mouse movements, or command-line executions.
IF Condition
The IF condition checks if a statement is true and executes subsequent actions if the condition is met.
Example: Basic IF Statement
1 | IF | FILE | C:\MMM\Skip.mmmacro | EXIST | CONTINUE
Explanation - Basic IF Statement
- Line 1: This checks if the file
C:\MMM\Skip.mmmacroexists. If it does, the macro continues execution; otherwise, it halts.
IF NOT Condition
The IF NOT condition evaluates whether a statement is not true and executes actions if the condition evaluates as false.
Example: Basic IF NOT Statement
1 | IF NOT | FILE SIZE | C:\MMM\Skip.mmmacro | IS | 2929 | STOP
Explanation - Basic IF NOT Statement
- Line 1: This checks if the size of the file
C:\MMM\Skip.mmmacrois not 2929 bytes. If this condition is true, the macro stops.
IF THEN ELSE
The IF THEN ELSE block allows for branching logic, where actions are executed based on whether a condition is true or false.
Example 1: Basic Block
1 | IF | BOOLEAN VARIABLE | %BOOLEAN% | IS TRUE | THEN
2 | RUN ACTION | MESSAGE PROMPT | TRUE
3 | IF | ELSE
4 | RUN ACTION | MESSAGE PROMPT | FALSE
5 | IF | END IF
Explanation - Basic IF THEN ELSE Block
- Line 1: Starts the
IF THEN ELSEblock and checks if the boolean variable%BOOLEAN%isTRUE. - Line 2: Executes the
MESSAGE PROMPTaction to display “TRUE” if the condition is met. - Line 3: Starts the
ELSEblock. - Line 4: Executes the
MESSAGE PROMPTaction to display “FALSE” if the condition is not met. - Line 5: Ends the
IF THEN ELSEblock.

Nested IF Blocks
You can nest IF statements within other IF blocks to evaluate multiple conditions simultaneously.
Example: Nested IF Blocks
1 | IF | FOLDER | C:\Macro\File\pics\ | EXIST | THEN
2 | IF | DETECT IMAGE | image path C:\File\pics\capture.bmp::match quick::move mouse yes | IMAGE FOUND | THEN
3 | RUN ACTION | MOUSE CLICK | Left click at %mouse_x% %mouse_y% 10 times with 10 ms delay and lock the mouse
4 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %boolImageFound%::TRUE
5 | IF | ELSE
6 | RUN ACTION | DEFINE PIXEL RANGE VARIABLE | %PIXEL_RANGE%::At location [X:89 Y:124 W:100 H:100]::Save image to C:\File\pics\capture.bmp
7 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %boolImageFound%::FALSE
8 | IF | END IF
9 | IF | END IF
Explanation - Nested IF Blocks
- Lines 1: Starts the root
IFblock and checks if a folder exists and detects an image in the folder. - Lines 2: Starts the nested
IF THEN ELSEblock and evaluates theDETECT IMAGEcondition. - Lines 3–4: Executes actions when the image is found.
- Lines 5: Starts the
ELSEblock for the nestedIFstatement. - Lines 6–7: Executes alternative actions if the image is not found.
- Line 8: Ends the nested
IF THEN ELSEblock. - Line 9: Ends the root
IFblock.
ELSE Condition
The ELSE condition complements IF and IF NOT statements, enabling alternate logic execution when the primary condition evaluates to FALSE. In essence, ELSE specifies an alternate flow of execution, functioning as a fallback mechanism for conditions that fail to meet the TRUE criteria.
Notably, ELSE cannot be paired with an initial condition that uses the CONTINUE action. This limitation exists because CONTINUE enforces that the primary condition must evaluate to TRUE before allowing the macro to proceed, rendering the ELSE branch unreachable.
Example 1: Simple ELSE Statement
* | Line | Condition | Action
* | This macro checks if the file C:\MMM\Skip.mmmacro exists. If it does, it displays a message. If not, it creates a new file.
* | if the file exist, goto line 5. If not, goto line 2
1 | IF | FILE | C:\MMM\Skip.mmmacro | EXIST | GOTO MACRO LINE | 5 | ELSE | 1 | RUN ACTION | GOTO MACRO LINE | 2
* | The file does not exist, prompt the user and then create a new file.
2 | MESSAGE PROMPT | File does not exist. Creating now...::File not found::0
3 | RUN ACTION | FILE CREATE | D:\Macro\Bytes\file1.out::B::100
* | Output to the file and then run the action to go to line 6
4 | RUN ACTION | OUTPUT TO FILE | D:\Macro\Bytes\file1.out::APPEND::%DATE% %TIME% | AND | 4 | RUN ACTION | GOTO MACRO LINE | 6
* | The file exists, display a message - Line 1 sent us to line 5, Line 4 skips to line 6
5 | RUN ACTION | MESSAGE PROMPT | File exists::File found::0
* | Macro execution complete - Line 4 sent us to line 6 and line 5 continues to line 6
6 | RUN ACTION | MESSAGE PROMPT | Macro execution complete::Success::0
Explanation - Simple ELSE Statement
- If the file
C:\MMM\Skip.mmmacroexists, the macro will display a message indicating the file was found and then proceed to line 6. - If the file does not exist, the macro will display a message indicating the file was not found, create a new file, output the date and time to the file, and then proceed to line 6.
Example 2: Nested ELSE Condition
1 | IF | FILE | C:\MMM\Skip.mmmacro | EXIST | GOTO MACRO LINE | 7 | ELSE | 1 | IF | FILE | C:\MMM\Skip2.mmmacro | EXIST | ADD MACRO FROM FILE | C:\MMM\Skip2.mmmacro
Explanation - Nested ELSE Condition
- If the first condition is true (the file exists), the macro will skip to line 7 and end the
IFblock. - If the first condition evaluates to false (the file does not exist), the macro will evaluate a second condition to check if the file
C:\MMM\Skip2.mmmacroexists. - If the second file exists, the macro will run the
ADD MACRO FROM FILEaction to include the contents ofC:\MMM\Skip2.mmmacroin the current macro.
Alternative Syntax:
1 | IF | FILE | C:\MMM\Skip.mmmacro | EXIST | THEN
2 | GOTO MACRO LINE | 7
3 | IF | ELSE
4 | IF | FILE | C:\MMM\Skip2.mmmacro | EXIST | THEN
5 | RUN ACTION | ADD MACRO FROM FILE | C:\MMM\Skip2.mmmacro
6 | IF | END IF
7 | IF | END IF
- The alternative syntax provides a more structured approach with the use of the
IF THEN ELSEblock, enhancing readability and maintainability.
Adding ELSE to a Condition
To add ELSE to a condition:
- Create your initial
IForIF NOTcondition but do not click “OK”. - Check the
ELSEcheckbox. - Select either
IF,IF NOT, orRUN ACTIONas the condition. This will add the condition after theELSE.
Syntax Examples
[LINE #] | [FIRST CONDITION] | ELSE | [LINE #] | [CONDITION][LINE #] | [FIRST CONDITION] | ELSE | [LINE #] | [ACTION]
- Select your object. This will add an object condition after the condition.
Extended Syntax Example
[LINE #] | [FIRST CONDITION] | ELSE | [LINE #] | [CONDITION] | [OBJECT] | [OPERATOR] | [ACTION]
Best Practices
- It is best to follow this procedure for each
ELSEcondition added to ensure proper functionality and clarity in your macro logic. - Use
ELSEto create fallback actions when the primary condition evaluates toFALSE. - Avoid using
ELSEwith conditions that employ theCONTINUEaction to maintain logical consistency. - Nest
ELSEconditions to create multi-level branching logic for complex macro workflows. - Test your
ELSEconditions thoroughly to ensure they execute as expected. - Use
IF THEN ELSEblocks instead of the singularELSEfor more complex branching logic.
AND Condition
AND is used to append additional actions and conditions to macro lines once they evaluate to TRUE. This allows for streamlined execution of multiple actions or conditions within a single line.
Adding AND to a Macro Line
To add AND to a macro line:
- Left-click to select the macro line.
- Right-click to bring up the Edit Menu and select Edit Entry.
- Select Action, then Add AND Action.
Example 1: Basic AND Usage
1 | IF | FILE | D:\Macro\OUTPUT\output.txt | EXIST | MESSAGE PROMPT | File Exists - Starting Output Write::File Exists::0 | AND | 2 | RUN ACTION | OUTPUT TO FILE | D:\Macro\OUTPUT\output.txt::APPEND::%STRING%
Explanation - Basic AND Usage
- If the file
output.txtexists, the macro will display a message prompt and, usingAND, also output the variable%STRING%to the file. - If the file does not exist, the message prompt will not show, and the
ANDaction will not execute.
Alternative Syntax:
1 | IF | FILE | D:\Macro\OUTPUT\output.txt | EXIST | THEN
2 | RUN ACTION | MESSAGE PROMPT | File Exists - Starting Output Write::File Exists::0
3 | RUN ACTION | OUTPUT TO FILE | D:\Macro\OUTPUT\output.txt::APPEND::%STRING%
4 | IF | END IF
- The alternative syntax provides a more structured approach to the
IF THEN ELSEblock, enhancing readability and maintainability.
Example 2: AND with ELSE
1 | IF | FILE | D:\Macro\OUTPUT\output.txt | EXIST | MESSAGE PROMPT | File Exists - Starting Output Write::File Exists::0 | AND | 2 | RUN ACTION | OUTPUT TO FILE | D:\Macro\OUTPUT\output.txt::APPEND::%STRING% | ELSE | 3 | RUN ACTION | MESSAGE PROMPT | File does NOT Exist::File not found::0
Explanation - AND with ELSE
- If the file
output.txtexists, the macro performs theMESSAGE PROMPTaction and appends%STRING%to the file. - If the file does not exist, the macro skips the message prompt output and the
ANDstatement and instead executes theELSEaction to display a message indicating the file was not found.
Alternative Syntax:
1 | IF | FILE | D:\Macro\OUTPUT\output.txt | EXIST | THEN
2 | RUN ACTION | MESSAGE PROMPT | File Exists - Starting Output Write::File Exists::0
3 | RUN ACTION | OUTPUT TO FILE | D:\Macro\OUTPUT\output.txt::APPEND::%STRING%
4 | IF | ELSE
5 | RUN ACTION | MESSAGE PROMPT | File does NOT Exist::File not found::0
6 | IF | END IF
- The alternative syntax provides a more structured approach to the
IF THEN ELSEblock, enhancing readability and maintainability. - The
ELSEblock is clearly separated from the primary condition, ensuring a logical flow of execution.
Example 3: Keypress and Mouse Movement with AND
1 | 2098 | 363 | 1000 | Keypress Output 1 | AND | 4 | 1883 | 206 | 10 | Mouse Movement | AND | 4 | 1883 | 206 | 10 | Keypress Output 2
Explanation - Keypress and Mouse Movement with AND
- Combines multiple actions: a keypress, mouse movement, and another keypress within a single macro line using
AND.
Notes on AND
ANDactions or conditions only execute if the preceding condition or action evaluates toTRUEor succeeds.ANDdoes not add additional condition evaluation to a macro statement. Instead, it chains multiple actions into one logical flow.- Using
ANDin conjunction withELSEensures logical separation of conditions and fallback behavior.
Typical Use Case Example
1 | IF | PROCESS ID | 12888 | EXIST | KILL PROCESS ID | 12888 | AND | 2 | IF | PROCESS ID | 12888 | NOT EXIST | MESSAGE PROMPT | Process 12888 Killed::Process 12888 Status::0
Explanation - Typical Use Case
- If the process with ID
12888exists, it will be terminated. After termination, the macro checks if the process no longer exists and displays a message prompt.
Advanced Example: Chaining Multiple AND Statements
1 | RUN ACTION | RUN VIA CMD /C | start d:\process_generate.bat | AND | 2 | RUN ACTION | WAIT MINUTES | 1 | AND | 3 | IF | PROCESS NAME | process_build | EXIST | MESSAGE PROMPT | process_generate successful::SUCCESS::0 | ELSE | 3 | RUN ACTION | MESSAGE PROMPT | process_generate unsuccessful::FAIL::0
Explanation - Chaining Multiple AND Statements
- Executes a series of actions: runs a batch file, waits for a minute, checks for a process, and displays success or failure messages based on the condition.
Alternative Syntax:
1 | RUN ACTION | RUN VIA CMD /C | start d:\process_generate.bat
2 | RUN ACTION | WAIT MINUTES | 1
3 | IF | PROCESS NAME | process_build | EXIST | THEN
4 | RUN ACTION | MESSAGE PROMPT | process_generate successful::SUCCESS::0
5 | IF | ELSE
6 | RUN ACTION | MESSAGE PROMPT | process_generate unsuccessful::FAIL::0
7 | IF | END IF
- The alternative syntax provides a more structured approach to the
IF THEN ELSEblock, enhancing readability and maintainability.
AND is a powerful feature for combining multiple actions or conditions into a cohesive workflow. Proper use of AND can simplify and condense complex macro logic.
FOR Loops
FOR loops are a powerful tool in Mini Mouse Macro that allow for iterating over ranges, files, or lines. They add several internal variables that can be used for evaluation during execution.
Internal Variables
The following internal variables are available for use within FOR loops:
%I%: The count for the current iteration of theFORloop.%LINE%: Used inFOR EACH LINEloops, holds the current text line in a file.%FILE%: The full file path and name of the current file in aFOR EACH FILEloop.%FILE.NAME%: The file name of the current file in aFOR EACH FILEloop.%FILE.EXT%: The file extension of the current file (e.g.,.txt,.rtf).%FILE.PATHROOT%: The root of the file path for the current file.%FILE.PATH%: The file path without the file name of the current file.%FILE.ACCESSTIME%: The last access time of the current file.%FILE.WRITETIME%: The last write time of the current file.%FILE.CREATIONTIME%: The creation time of the current file.
There are two types of FOR loops in Mini Mouse Macro:
FOR EACHloop: Iterates through files in a folder or lines in a file.FOR Iloop: Iterates over a numerical range.
FOR EACH Loops
FOR EACH loops provide the ability to iterate over files in folders or lines in files. The types of FOR EACH loops are:
FOR | EACH | FILE IN | FOLDER | DOFOR | EACH | FILE IN -R | FOLDER | DOFOR | EACH | LINE IN | FILE | DOFOR | EACH | LINE IN | FILE | RUNFOR | I | = | START TO END | NEXT
FOR EACH FILE IN FOLDER
FOR EACH FILE IN FOLDER iterates over all files in a specified folder.
Example: Iterating Over Files in a Folder
1 | FOR | EACH | FILE IN | C:\Macro\Files | DO
2 | RUN ACTION | MESSAGE PROMPT | File: %FILE.NAME% Path: %FILE.PATH%
3 | FOR | NEXT
Explanation - Iterating Over Files in a Folder
- Line 1: Iterates through all files in
C:\Macro\Files. - Line 2: Displays the file name and path for each file.
- Line 3: Ends the loop.

Example: Recursive File Iteration
1 | FOR | EACH | FILE IN -R | C:\Macro | DO
2 | RUN ACTION | MESSAGE PROMPT | File: %FILE.NAME%
3 | FOR | NEXT
Explanation - Recursive File Iteration
- Line 1: Recursively iterates through all files in the
C:\Macrodirectory. - Line 2: Displays the name of each file.
- Line 3: Ends the loop.
Example: Encrypting Files Recursively
1 | FOR | EACH | FILE IN -R | E:\DOCS | DO
2 | IF | STRING VARIABLE | %FILE.EXT% | IS NOT | .aes | ENCRYPT FILE (AES) | %FILE%::MyPassword::DELETE_ORIGINAL
3 | FOR | NEXT
Explanation - Encrypting Files Recursively
- Line 1: Recursively iterates through all files in the
E:\DOCSdirectory. - Line 2: Checks if the file extension is not
.aesand encrypts the file if the condition is met. - Line 3: Ends the loop.
FOR EACH LINE IN FILE
FOR EACH LINE IN FILE iterates over each line in a specified file.
Example: Processing Lines in a File
1 | FOR | EACH | LINE IN | C:\Macro\input.txt | DO
2 | RUN ACTION | MESSAGE PROMPT | Line Content: %LINE%
3 | FOR | NEXT
Explanation - Processing Lines in a File
- Line 1: Iterates through each line in the file
input.txt. - Line 2: Displays the content of the current line.
- Line 3: Ends the loop.
Example: Processing Lines in Files Recursively
1 | FOR | EACH | FILE IN -R | E:\docs | DO
2 | FOR | EACH | LINE IN | %file% | DO
3 | IF | STRING VARIABLE | %LINE% | CONTAINS | %date% - Out | OUTPUT TO FILE | E:\out.txt::APPEND::%file%;
4 | FOR | NEXT
5 | FOR | NEXT
Explanation - Processing Lines Recursively
- Line 1: Recursively iterates through all files in the
E:\docsdirectory. - Line 2: Iterates through each line in the current file.
- Line 3: Checks if the current line contains the specified date and appends the file name to
E:\out.txtif the condition is met. - Lines 4-5: End the nested loops.
Example: Sending UDP Packets Based on Ping Response
1 | FOR | EACH | LINE IN | D:\Macro\TX\send.txt | DO
2 | IF | NETWORK HOST PING REPLY | %LINE% | SUCCESSFUL | SEND UDP PACKET STRING | %LINE%::41414::BEGIN
3 | IF | RECEIVE UDP PACKET STRING | %LINE%::41413::FIN::30000 | STRING FOUND | SEARCH FOR STRING | OUTPUT TO FILE | D:\Macro\RX\hostRX_110.txt::APPEND::.D.%DATE%.T.%TIME%.Success_
4 | FOR | NEXT
Explanation - Sending UDP Packets
- Line 1: Iterates through each line in
send.txt. - Line 2: Sends a ping to the current line’s value. If successful, sends a UDP packet with the string ‘BEGIN’ to port 41414.
- Line 3: Waits 30 seconds for a UDP reply with the string ‘FIN’ from port 41413. If received, appends success information to
hostRX_110.txt. - Line 4: Ends the loop.
Sample Input send.txt File
192.168.0.10 192.168.0.15 192.168.0.20
This file send.txt contains the IP addresses to which the macro will send UDP packets based on the ping response.
Sample Output hostRX_110.txt File
.D.2021-09-01.T.12-00-00.Success_192.168.0.10 .D.2021-09-01.T.12-00-30.Success_192.168.0.15 .D.2021-09-01.T.12-01-00.Success_192.168.0.20
FOR EACH LINE IN FILE RUN
FOR EACH LINE IN FILE RUN processes each line in a file as a separate macro.
Example: Running Commands from Macro Files
1 | FOR | EACH | LINE IN | D:\Macro\commands1.mmmacro | RUN
2 | FOR | EACH | LINE IN | D:\Macro\commands2.mmmacro | RUN
3 | FOR | EACH | LINE IN | D:\Macro\commands3.mmmacro | RUN
4 | FOR | EACH | LINE IN | D:\Macro\commands4.mmmacro | RUN
Explanation - Running Commands from Macro Files
- Lines 1-4: Steps through each command in the specified
.mmmacrofiles. Each file is processed line by line, and the next file begins after the previous one completes.
Notes on FOR EACH LINE IN FILE RUN
- This command works best with
.mmmacrofiles containing no flow control. - Mini Mouse Macro expects the same format as a saved
.mmmacrofile. - FOR loops and GOTO statements within these files will not work.
FOR I Loops
FOR I loops iterate over a range of numbers, making it easy to repeat actions a specific number of times.
Example: Simple Number Iteration
1 | FOR | I | = | 1 TO 10 | NEXT
2 | RUN ACTION | MESSAGE PROMPT | Iteration: %I%
3 | FOR | NEXT
Explanation - Simple FOR I Loop
- Line 1: Initializes a loop to iterate from 1 to 10.
- Line 2: Displays the current iteration number.
- Line 3: Ends the loop.
Example: Conditional FOR I Loop
1 | FOR | I | = | 1 TO 10 | NEXT
2 | IF | BOOLEAN VARIABLE | %BOOLEAN% | IS TRUE | THEN
3 | RUN ACTION | MESSAGE PROMPT | Iteration: %I% is valid.
4 | IF | END IF
5 | FOR | NEXT
Explanation - Conditional FOR I Loop
- Line 1: Initializes a loop to iterate from 1 to 10.
- Lines 2–4: Executes actions only if the boolean variable
%BOOLEAN%isTRUE. - Line 5: Ends the loop.
Notes on FOR Loops
- Nested Loops: FOR loops can be nested for more complex iterations.
- Internal Variables: Use the provided internal variables to interact dynamically with files, lines, and other elements.
- Recursive Searches: Use
-Rto enable recursive folder searching.
This section comprehensively covers FOR loops, ensuring all content from conditions.txt is included. Let me know if more details or adjustments are required!
RUN ACTION
The RUN ACTION command is a versatile way to perform specific tasks within Mini Mouse Macro. It allows you to execute predefined actions, such as displaying messages, moving the mouse, or modifying files.
The full list of available actions can be found in the Actions Condition guide.
Example 1: Displaying a Message Prompt
1 | RUN ACTION | MESSAGE PROMPT | Task completed successfully!::Success::0
Explanation - Message Prompt
- Line 1: Executes a
MESSAGE PROMPTaction displaying the message “Task completed successfully!” with the title “Success.”
Example 2: Moving the Mouse to a Location
1 | RUN ACTION | MOUSE MOVEMENT | -1414-912:10,-1412-912:10,-1411-912:10,-1409-912:26,-1407-912:24,-1407-913:10,-1406-913:14
Explanation - Mouse Movement
- Line 1: Moves the mouse cursor through a series of screen coordinates specified in the format X-Y:duration. Each coordinate pair represents a point the mouse will move to, with the duration indicating how long the movement should take.
Example 3: Defining a Variable
1 | RUN ACTION | DEFINE STRING VARIABLE | %username%::JohnDoe
Explanation - Variable Definition
- Line 1: Creates a string variable
%username%and assigns it the valueJohnDoe.
Example 4: Performing a File Operation
1 | RUN ACTION | FILE COPY | C:\Source\file.txt::C:\Destination\file.txt
Explanation - File Copy
- Line 1: Copies the file
file.txtfrom theC:\Sourcedirectory to theC:\Destinationdirectory.
Example 5: Running a Command-Line Task
1 | RUN ACTION | RUN VIA CMD /C | echo Hello, World!
Explanation - Command Execution
- Line 1: Executes a command-line action to display “Hello, World!” in the terminal.
Example 6: Waiting for a Specific Duration
1 | RUN ACTION | WAIT SECONDS | 5
Explanation - Wait Command
- Line 1: Pauses the macro for 5 seconds before continuing execution.
Notes on Flow Control
IFIF,IF NOT, andIF THEN ELSEblocks can be nested to create complex logic structures.ELSEconditions must follow anIForIF NOTstatement and cannot be used if the initial condition employs aCONTINUEaction. This restriction ensures the logical flow remains coherent, asCONTINUEmandates the primary condition to evaluate asTRUEbefore proceeding.- All
IFblocks must close with anEND IF.
FORFORloops can iterate over ranges, files, or lines, and must be concluded with aNEXTstatement. They provide internal variables like%I%,%LINE%, and%FILE%for dynamic interaction during execution.FOR EACHloops can iterate over files in folders or lines in files, whileFOR Iloops iterate over numerical ranges. They offer internal variables for dynamic evaluation during execution.
ANDANDare used to chain multiple actions or conditions within a single line for streamlined execution.ANDactions or conditions only execute if the preceding condition or action evaluates toTRUEor succeeds.Nesting Conditions- Nested blocks can significantly enhance macro complexity but should be used cautiously to maintain clarity.