Boolean Variables in Mini Mouse Macro: A Comprehensive Guide
Table of Contents
Introduction
In Mini Mouse Macro, BOOLEAN VARIABLE
objects represent logical states, holding either TRUE
or FALSE
values. They are essential for controlling the flow of your macros based on conditions, enabling decision-making and conditional execution within your automations. This guide will explore boolean variables in detail, covering their definition, usage, and practical examples.
Defining Boolean Variables
Boolean variables in Mini Mouse Macro can be defined using the internal %BOOLEAN%
name or any custom name, providing flexibility and clarity in your macros. A boolean variable that hasn’t been explicitly defined defaults to the FALSE
state.
Naming Conventions
As with other variable types, it’s best practice to choose descriptive names for your boolean variables. Instead of generic names like %BOOLEAN%
or %BOOLEAN1%
, use names that clearly indicate the condition or state they represent, such as %IsFileOpen%
, %ProcessCompleted%
, or %UserConfirmed%
.
Definition Examples
Defining with the Default Name
1 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::TRUE
This line of code defines a boolean variable named %BOOLEAN%
and sets its value to TRUE
.
Defining with Custom Names
1 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %DataLoaded%::TRUE
2 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %IsValid%::FALSE
3 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %RetryNeeded%::TRUE
Here, we define three boolean variables with descriptive names:
%DataLoaded%
is set toTRUE
, likely indicating that some data has been successfully loaded.%IsValid%
is set toFALSE
, possibly representing the validity state of some input or data.%RetryNeeded%
is set toTRUE
, indicating that a retry operation might be required.
Alternative Syntax
1 | RUN ACTION | Switch::TRUE
This will define the %Switch%
variable and set it to TRUE
.
Boolean Variable Evaluations
Boolean variables are primarily used in conditional statements to control the flow of your macros. Mini Mouse Macro provides operators to evaluate the state of boolean variables.
Available Operators
- IS TRUE: Checks if a boolean variable is
TRUE
. - IS FALSE: Checks if a boolean variable is
FALSE
.
Examples
Using the IS TRUE
Operator
1 | IF | BOOLEAN VARIABLE | %ProcessCompleted% | IS TRUE | RUN ACTION | MESSAGE PROMPT | Process completed successfully!::Success
This code checks if the %ProcessCompleted%
variable is TRUE
. If it is, a message prompt indicating successful completion is displayed.
Using the IS FALSE
Operator
1 | IF | BOOLEAN VARIABLE | %FileExists% | IS FALSE | RUN ACTION | CREATE FILE | D:\Data\NewFile.txt
This code checks if the %FileExists%
variable is FALSE
. If it is, a new file is created.
Combining with GOTO
for Conditional Branching
10 | IF | BOOLEAN VARIABLE | %BOOLEAN% | IS TRUE | GOTO MACRO LINE | Down | ELSE | 10 | RUN ACTION | GOTO MACRO LINE | Up 5
This code checks if the %BOOLEAN%
variable is TRUE
. If it is, the macro execution jumps forward 1 line. Otherwise it jumps up 5 lines from the current line.
Using an INPUT BOX
to set a Boolean Variable
1 | RUN ACTION | INPUT BOX | Would you like to start (Y/N)::Start::PROMPT_YES_NO::BOOLEAN
2 | IF | BOOLEAN VARIABLE | %BOOLEAN% | IS FALSE | MESSAGE PROMPT | Ok - Macro is cancelled ::Macro Stopped::1
3 | IF | BOOLEAN VARIABLE | %BOOLEAN% | IS FALSE | STOP
- Line 1: An
INPUT BOX
prompts the user with a Yes/No question. The user’s response sets the value of the%BOOLEAN%
variable. Selecting “Yes” sets it toTRUE
, “No” sets it toFALSE
. - Lines 2-3: If
%BOOLEAN%
isFALSE
(meaning the user selected “No”), a message is displayed, and the macro stops.
Further Exploration
This guide has covered the essentials of boolean variables in Mini Mouse Macro. To further enhance your skills, consider exploring the following topics:
- Integer Variables: Learn about integer variables for working with whole numbers and mathematical operations.
- Decimal Variables: Learn about decimal variables for working with floating-point numbers.
- String Variables: Explore string variables for handling text and character data.
- Pixel Variables: Dive into pixel variables for screen-based evaluations and interactions.
- Internal Variables: Explore predefined internal variables for dynamic content and system information.
- Control Flow: Dive deeper into control flow statements, such as
IF
,ELSE
, andGOTO
, to create more complex logic. - Advanced Actions: Investigate advanced actions, such as file operations, system commands, and external program execution.
- Community Forums: Engage with the Mini Mouse Macro community to share knowledge, ask questions, and learn from others.
By continuing to learn and experiment, you can master Mini Mouse Macro and create powerful automations to streamline your tasks and boost your productivity.