Decimal Variables in Mini Mouse Macro: A Comprehensive Guide
Table of Contents
Introduction
In Mini Mouse Macro, DECIMAL VARIABLE
objects are used to store and manipulate numbers with decimal points, providing a way to work with floating-point values. They are essential for calculations and operations that require precision beyond whole numbers. This guide will provide a thorough understanding of decimal variables, including their definition, usage, and examples.
Defining Decimal Variables
Decimal variables in Mini Mouse Macro can be defined using the internal %DECIMAL%
name or any custom name. Choosing descriptive names for your variables is a good practice as it improves the readability and maintainability of your macros. An undeclared decimal variable defaults to the value of 0
.
Naming Conventions
When naming decimal variables, opt for names that reflect their purpose or the nature of the value they hold. For example, instead of %DECIMAL%
or %DECIMAL1%
, use names like %Price%
, %TaxRate%
, or %Measurement%
.
Definition Examples
Defining with the Default Name
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %DECIMAL%::10.55
This line of code defines a decimal variable named %DECIMAL%
and assigns it the value 10.55
.
Defining with Custom Names
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %UnitPrice%::25.99
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Discount%::0.15
3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %TotalCost%::0.0
Here, we define three decimal variables with descriptive names:
%UnitPrice%
is assigned the value25.99
.%Discount%
is assigned the value0.15
.%TotalCost%
is initialized to0.0
.
Alternative Syntax
1 | RUN ACTION | DECIMAL::1.0
This will define the %DECIMAL%
variable with the value 1.0
.
Defining variables can also be done manually from the ‘Variable’ settings page.
Mathematical Operations
Mini Mouse Macro allows you to perform various mathematical operations with decimal variables, similar to integer variables.
Available Operators
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Power of (^)
- Modulus (%)
Operator Examples with Named Variables
Addition
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Subtotal%::125.50
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Tax%::8.25
3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Total%::%Subtotal%+%Tax%
- Lines 1-2: We define
%Subtotal%
and%Tax%
. - Line 3:
%Total%
is calculated by adding%Subtotal%
and%Tax%
.
Subtraction
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %OriginalPrice%::99.99
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %DiscountAmount%::10.00
3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %FinalPrice%::%OriginalPrice%-%DiscountAmount%
- Lines 1-2: We define
%OriginalPrice%
and%DiscountAmount%
. - Line 3:
%FinalPrice%
is calculated by subtracting%DiscountAmount%
from%OriginalPrice%
.
Multiplication
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Length%::5.5
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Width%::2.5
3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Area%::%Length%*%Width%
- Lines 1-2: We define
%Length%
and%Width%
. - Line 3:
%Area%
is calculated by multiplying%Length%
by%Width%
.
Division
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %TotalDistance%::250.0
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %FuelUsed%::12.5
3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Efficiency%::%TotalDistance%/%FuelUsed%
- Lines 1-2: We define
%TotalDistance%
and%FuelUsed%
. - Line 3:
%Efficiency%
is calculated by dividing%TotalDistance%
by%FuelUsed%
.
Power Of
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Base%::2.0
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Exponent%::3.0
3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Result%::%Base%^%Exponent%
- Lines 1-2: We define
%Base%
and%Exponent%
. - Line 3:
%Result%
is calculated as%Base%
raised to the power of%Exponent%
.
Modulus
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Dividend%::10.0
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Divisor%::3.0
3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Remainder%::%Dividend%%%Divisor%
- Lines 1-2: We define
%Dividend%
and%Divisor%
. - Line 3:
%Remainder%
is calculated as the remainder of%Dividend%
divided by%Divisor%
.
Logical Evaluations
Decimal variables can be used in logical evaluations, similar to integer variables.
Available Logical Operators
- Equal to (=)
- Not equal to (!=)
- Greater than (>)
- Greater than or equal to (>=)
- Less than (<)
- Less than or equal to (<=)
Logical Operator Examples with Named Variables
Equal To
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Value1%::1.23
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Value2%::1.23
3 | IF | DECIMAL VARIABLE | %Value1% | = | %Value2% | RUN ACTION | MESSAGE PROMPT | Values are equal::Match
- Lines 1-2: We define
%Value1%
and%Value2%
. - Line 3: The
IF
statement checks if%Value1%
is equal to%Value2%
, displaying a message if true.
Not Equal To
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Temp1%::25.5
2 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Temp2%::26.0
3 | IF | DECIMAL VARIABLE | %Temp1% | != | %Temp2% | RUN ACTION | MESSAGE PROMPT | Temperatures are different::Confirmed
- Lines 1-2: We define
%Temp1%
and%Temp2%
. - Line 3: The
IF
statement checks if%Temp1%
is not equal to%Temp2%
, displaying a message if true.
Greater Than
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Score%::85.5
2 | IF | DECIMAL VARIABLE | %Score% | > | 80.0 | RUN ACTION | MESSAGE PROMPT | Score is greater than 80::Pass
- Line 1: We define
%Score%
. - Line 2: The
IF
statement checks if%Score%
is greater than80.0
, displaying a message if true.
Greater Than or Equal To
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Height%::1.75
2 | IF | DECIMAL VARIABLE | %Height% | >= | 1.75 | RUN ACTION | MESSAGE PROMPT | Height is at least 1.75::Eligible
- Line 1: We define
%Height%
. - Line 2: The
IF
statement checks if%Height%
is greater than or equal to1.75
, displaying a message if true.
Less Than
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Price%::49.99
2 | IF | DECIMAL VARIABLE | %Price% | < | 50.0 | RUN ACTION | MESSAGE PROMPT | Price is less than 50::Sale
- Line 1: We define
%Price%
. - Line 2: The
IF
statement checks if%Price%
is less than50.0
, displaying a message if true.
Less Than or Equal To
1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %Quantity%::9.5
2 | IF | DECIMAL VARIABLE | %Quantity% | <= | 10.0 | RUN ACTION | MESSAGE PROMPT | Quantity is 10 or less::Low Stock
- Line 1: We define
%Quantity%
. - Line 2: The
IF
statement checks if%Quantity%
is less than or equal to10.0
, displaying a message if true.
Decimal Output
Decimal variable contents can be used in macro’s with the %DECIMAL%
word or the defined custom name.
Examples
Basic Decimal Output
1 | 2409 | 790 | 200 | Keypress My decimal variable is equal to %Decimal%
- Line 1: Simulates a keypress action at the mouse position
(X=2409, Y=790)
with a delay of 200 milliseconds before typing the textMy decimal variable is equal to %Decimal%
. The%Decimal%
variable dynamically outputs its current value during execution.
Using Variables in combination with other variable types output
1 | 2739 | 701 | 200 | Keypress My integer is %INTEGER%. A random is: %random_1-100000% and here is my decimal:%Decimal%
- Line 1: Simulates a keypress action at the mouse position
(X=2739, Y=701)
with a delay of 200 milliseconds before typing the textMy integer is %INTEGER%. A random is: %random_1-100000% and here is my decimal: %Decimal%
. This dynamically outputs the current values of%INTEGER%
, a random number between 1 and 100,000 (%random_1-100000%
), and%Decimal%
.
Further Exploration
This guide has covered the essentials of decimal 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.
- Boolean Variables: Explore boolean variables for logical conditions and flow control.
- 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.