Prism.js Language Definition: mmm

Integer Variables in Mini Mouse Macro: A Comprehensive Guide

Table of Contents
  1. Introduction
  2. Defining Integer Variables
    1. Naming Conventions
    2. Definition Examples
      1. Defining with Default Name
      2. Defining with Custom Names
      3. Alternative Syntax
  3. Mathematical Operations
    1. Available Operators
    2. Operator Examples with Named Variables
      1. Addition
      2. Subtraction
      3. Multiplication
      4. Division
      5. Power Of
      6. Modulus
  4. Logical Evaluations
    1. Available Logical Operators
    2. Logical Operator Examples with Named Variables
      1. Equal To
      2. Not Equal To
      3. Greater Than
      4. Greater Than or Equal To
      5. Less Than
      6. Less Than or Equal To
      7. Is Even
      8. Is Odd
  5. Working with Random Numbers
    1. Random Number Generation
    2. Examples with Named Variables
      1. Generating a Basic Random Number
      2. Generating a Random Number within a Specific Range
      3. Using Random Numbers in Conditional Logic
      4. Example: Wait a Random Amount of Time
      5. Example: Randomly Rename a file
      6. Example: Using Random in String variables
      7. Example: Using Random to input a keypress
  6. Best Practices
  7. Conclusion
  8. Further Exploration

Introduction

In Mini Mouse Macro, INTEGER VARIABLE objects are essential building blocks for creating dynamic and intelligent automations. They provide a way to store, manipulate, and evaluate whole numbers, enabling complex logic and calculations within your macros. This document provides a detailed explanation of integer variables, covering their definition, usage, and best practices. Understanding integer variables will significantly enhance your ability to create powerful and efficient macros.


Defining Integer Variables

Integer variables in Mini Mouse Macro are used to store whole numbers (numbers without a decimal point). These variables can be named using the internal %INTEGER% name or any other custom name for improved readability and organization. An undeclared integer variable defaults to the value of 0.

Naming Conventions

Choosing descriptive names for your variables is crucial for maintaining clarity and understanding, especially in complex macros. Instead of generic names like %INTEGER% or %INTEGER1%, opt for names that reflect the variable’s purpose, such as %Counter%, %TotalItems%, or %FileIndex%.

Definition Examples

Defining with Default Name

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::100

This line of code defines an integer variable named %INTEGER% and assigns it an initial value of 100.

Defining with Custom Names

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

Here, we define three integer variables with descriptive names:

  • %LoopCounter% is initialized to 0, likely to be used as a counter in a loop.
  • %Total% is set to 500, possibly representing a total count or sum.
  • %ProductID% is assigned 12345, indicating it might store a product identifier.

Alternative Syntax

1 | RUN ACTION | Count::100

This will define the %Count% variable with the value “100”


Mathematical Operations

Mini Mouse Macro empowers you to perform a variety of mathematical operations using integer variables. These operations are fundamental for calculations and data manipulation within your macros.

Available Operators

  • Addition (+): Adds two values together.
  • Subtraction (-): Subtracts one value from another.
  • Multiplication (*): Multiplies two values.
  • Division (/): Divides one value by another.
  • Power of (^): Raises a value to the power of another value.
  • Modulus (%): Returns the remainder of a division.

Operator Examples with Named Variables

Addition

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Sum%::0
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %Value1%::10
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %Value2%::25
4 | IF | INTEGER VARIABLE | %Value1% | + | %Value2%::=::%Sum% | RUN ACTION | DEFINE INTEGER VARIABLE | %Sum%::35
5 | MESSAGE PROMPT | The sum is: %Sum%::Output
  • Lines 1-3: We define three integer variables: %Sum%, %Value1%, and %Value2%, initializing them with 0, 10, and 25, respectively.
  • Line 4: This IF statement checks if %Value1% plus %Value2% is equal to %Sum%. In this initial state, it will not be, so the RUN ACTION to define %Sum% as 35 will not execute.
  • Line 5: Finally, a message prompt displays the value of %Sum%, which will be 0 based on the logic.

Subtraction

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Difference%::0
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %InitialValue%::50
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %Deduction%::15
4 | IF | INTEGER VARIABLE | %InitialValue% | - | %Deduction%::>=::0 | RUN ACTION | DEFINE INTEGER VARIABLE | %Difference%::%InitialValue%-%Deduction%
5 | MESSAGE PROMPT | The difference is: %Difference%::Result
  • Lines 1-3: We define %Difference%, %InitialValue%, and %Deduction% with initial values.
  • Line 4: The IF statement checks if %InitialValue% minus %Deduction% is greater than or equal to 0. If true, %Difference% is updated with the result of the subtraction.
  • Line 5: The message prompt displays the value of %Difference%.

Multiplication

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Product%::1
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %Factor1%::5
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %Factor2%::10
4 | RUN ACTION | DEFINE INTEGER VARIABLE | %Product%::%Factor1%*%Factor2%
5 | MESSAGE PROMPT | The product is: %Product%::Output
  • Lines 1-3: We define %Product%, %Factor1%, and %Factor2%.
  • Line 4: %Product% is updated to store the result of multiplying %Factor1% and %Factor2%.
  • Line 5: The message prompt displays the calculated product.

Division

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Quotient%::0
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %Dividend%::100
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %Divisor%::4
4 | IF | INTEGER VARIABLE | %Divisor% | != | 0 | RUN ACTION | DEFINE INTEGER VARIABLE | %Quotient%::%Dividend%/%Divisor%
5 | MESSAGE PROMPT | The quotient is: %Quotient%::Result
  • Lines 1-3: We define %Quotient%, %Dividend%, and %Divisor%.
  • Line 4: The IF statement checks if the %Divisor% is not equal to 0 to prevent division by zero. If not zero, %Quotient% is updated with the result of the division.
  • Line 5: The message prompt displays the calculated quotient.

Power Of

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Result%::0
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %Base%::2
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %Exponent%::3
4 | RUN ACTION | DEFINE INTEGER VARIABLE | %Result%::%Base%^%Exponent%
5 | MESSAGE PROMPT | The result is: %Result%::Output
  • Lines 1-3: We define %Result%, %Base%, and %Exponent%.
  • Line 4: %Result% is updated with the value of %Base% raised to the power of %Exponent%.
  • Line 5: The message prompt displays the result.

Modulus

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Remainder%::0
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %Number%::17
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %ModBase%::5
4 | RUN ACTION | DEFINE INTEGER VARIABLE | %Remainder%::%Number%%%ModBase%
5 | MESSAGE PROMPT | The remainder is: %Remainder%::Output
  • Lines 1-3: We define %Remainder%, %Number%, and %ModBase%.
  • Line 4: %Remainder% is assigned the remainder of the division of %Number% by %ModBase%.
  • Line 5: The message prompt displays the remainder.

Logical Evaluations

Integer variables can also be used in logical evaluations, allowing you to create conditional statements and control the flow of your macros based on comparisons.

Available Logical Operators

  • Equal to (=): Checks if two values are equal.
  • Not equal to (!=): Checks if two values are not equal.
  • Greater than (>): Checks if one value is greater than another.
  • Greater than or equal to (>=): Checks if one value is greater than or equal to another.
  • Less than (<): Checks if one value is less than another.
  • Less than or equal to (<=): Checks if one value is less than or equal to another.
  • Is Even: Checks if a number is even.
  • Is Odd: Checks if a number is odd.

Logical Operator Examples with Named Variables

Equal To

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Counter%::5
2 | IF | INTEGER VARIABLE | %Counter% | = | 5 | MESSAGE PROMPT | Counter is equal to 5::Match
  • Line 1: We define %Counter% and set it to 5.
  • Line 2: The IF statement checks if %Counter% is equal to 5. If true, the message prompt “Counter is equal to 5” is displayed.

Not Equal To

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Value%::10
2 | IF | INTEGER VARIABLE | %Value% | != | 20 | MESSAGE PROMPT | Value is not equal to 20::Confirmed
  • Line 1: We define %Value% and set it to 10.
  • Line 2: The IF statement checks if %Value% is not equal to 20. If true, the message prompt is shown.

Greater Than

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Score%::75
2 | IF | INTEGER VARIABLE | %Score% | > | 60 | MESSAGE PROMPT | Score is greater than 60::Pass
  • Line 1: We define %Score% and set it to 75.
  • Line 2: The IF statement verifies if %Score% is greater than 60, displaying a message if the condition is met.

Greater Than or Equal To

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Age%::18
2 | IF | INTEGER VARIABLE | %Age% | >= | 18 | MESSAGE PROMPT | Age is greater than or equal to 18::Eligible
  • Line 1: We define %Age% and set it to 18.
  • Line 2: The IF statement checks if %Age% is greater than or equal to 18, displaying a message if true.

Less Than

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Temperature%::15
2 | IF | INTEGER VARIABLE | %Temperature% | < | 20 | MESSAGE PROMPT | Temperature is less than 20::Cold
  • Line 1: We define %Temperature% and set it to 15.
  • Line 2: The IF statement checks if %Temperature% is less than 20, displaying a message if the condition is met.

Less Than or Equal To

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Quantity%::5
2 | IF | INTEGER VARIABLE | %Quantity% | <= | 5 | MESSAGE PROMPT | Quantity is less than or equal to 5::Low Stock
  • Line 1: We define %Quantity% and set it to 5.
  • Line 2: The IF statement verifies if %Quantity% is less than or equal to 5, showing a message if true.

Is Even

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Number%::4
2 | IF | INTEGER VARIABLE | %Number% | IS EVEN | MESSAGE PROMPT | Number is even::Confirmed
  • Line 1: We define %Number% and set it to 4.
  • Line 2: The IF statement checks if %Number% is even. If so, a message prompt confirms this.

Is Odd

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %Number%::7
2 | IF | INTEGER VARIABLE | %Number% | IS ODD | MESSAGE PROMPT | Number is odd::Confirmed
  • Line 1: We define %Number% and set it to 7.
  • Line 2: The IF statement checks if %Number% is odd. If true, a message prompt is displayed.

Working with Random Numbers

Mini Mouse Macro allows you to generate and utilize random numbers within your macros using the %RANDOM% variable. This feature adds an element of unpredictability and versatility to your automations.

Random Number Generation

  • %RANDOM%: Generates a random integer between 1 and 2147483647 (inclusive).
  • %RANDOM_x-y%: Generates a random integer within a specific range, from x to y (inclusive).

Examples with Named Variables

Generating a Basic Random Number

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %RandomValue%::%RANDOM%
2 | MESSAGE PROMPT | The random number is: %RandomValue%::Output
  • Line 1: We define %RandomValue% and assign it a random number generated by %RANDOM%.
  • Line 2: The message prompt displays the generated random number.

Generating a Random Number within a Specific Range

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %DiceRoll%::%RANDOM_1-6%
2 | MESSAGE PROMPT | You rolled a: %DiceRoll%::Result
  • Line 1: We define %DiceRoll% and assign it a random number between 1 and 6, simulating a dice roll.
  • Line 2: The message prompt displays the result of the dice roll.

Using Random Numbers in Conditional Logic

* | This macro selects a random option (1, 2, or 3) and displays a corresponding message.

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %RandomChoice%::%RANDOM_1-3%
    * | Define an integer variable `%RandomChoice%` and assign it a random value between 1 and 3.

2 | IF | INTEGER VARIABLE | %RandomChoice% | = | 1 | THEN
    * | Check if `%RandomChoice%` is equal to 1.
    3 | RUN ACTION | MESSAGE PROMPT | Option 1 selected::Choice::0::Information
        * | Display a message indicating that Option 1 was selected.
4 | IF | ELSE
    * | If `%RandomChoice%` is not 1, check the next condition.

    5 | IF | INTEGER VARIABLE | %RandomChoice% | = | 2 | THEN
        * | Check if `%RandomChoice%` is equal to 2.
        6 | RUN ACTION | MESSAGE PROMPT | Option 2 selected::Choice::0::Information
            * | Display a message indicating that Option 2 was selected.
    7 | IF | ELSE
        * | If `%RandomChoice%` is not 2, check the next condition.

        8 | IF | INTEGER VARIABLE | %RandomChoice% | = | 3 | THEN
            * | Check if `%RandomChoice%` is equal to 3.
            9 | RUN ACTION | MESSAGE PROMPT | Option 3 selected::Choice::0::Information
                * | Display a message indicating that Option 3 was selected.
        10 | IF | END IF
            * | End the block for Option 3.
    11 | IF | END IF
        * | End the block for Option 2.
12 | IF | END IF
    * | End the block for Option 1.
  • Line 1: Defines an integer variable %RandomChoice% with a random value between 1 and 3.
  • Lines 2-3: Checks if %RandomChoice% is equal to 1. If true, displays an information-style message prompt indicating “Option 1 selected.”
  • Line 4: Begins the ELSE block for when %RandomChoice% is not 1.
  • Lines 5-6: Checks if %RandomChoice% is equal to 2. If true, displays an information-style message prompt indicating “Option 2 selected.”
  • Line 7: Begins the ELSE block for when %RandomChoice% is not 2.
  • Lines 8-9: Checks if %RandomChoice% is equal to 3. If true, displays an information-style message prompt indicating “Option 3 selected.”
  • Line 10: Ends the block for checking option 3.
  • Line 11: Ends the block for checking option 2.
  • Line 12: Ends the block for checking option 1.

Example: Wait a Random Amount of Time

1 | RUN ACTION | DEFINE INTEGER VARIABLE | %WaitTime%::%RANDOM_5-15%
2 | RUN ACTION | WAIT SECONDS | %WaitTime%
  • Line 1: We define %WaitTime% and assign it a random number of seconds between 5 and 15.
  • Line 2: The macro will then wait for that random number of seconds.

Example: Randomly Rename a file

1 | IF | FOLDER | D:\Macro | EXIST | RUN VIA CMD /K | rename D:\macro Folder-%random_1-50%
  • Line 1: If the folder D:\Macro exists then rename it to a random name between 1 and 50.

Example: Using Random in String variables

1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::%random_1-10000%
  • Line 1: %STRING% variable will be defined with a random number between 1 and 10000.

Example: Using Random to input a keypress

1 | 2409 | 790 | 200 | Keypress %random_99-199%
  • Line 1: At X mouse position 2409 and Y mouse position 790 wait 200 milliseconds and they output the keypress %RANDOM_99-199%.

Best Practices

  • Use Descriptive Variable Names: Choose meaningful names for your integer variables to enhance code readability and maintainability.
  • Initialize Variables: Explicitly initialize your variables to avoid unexpected behavior.
  • Validate Inputs: When accepting user input or external data, validate the values to ensure they are within acceptable ranges and formats.
  • Comment Your Code: Add comments to explain complex logic and the purpose of your variables.
  • Test Thoroughly: Test your macros with different inputs and scenarios to ensure they work as expected.
  • Modularize Your Macros: Break down complex tasks into smaller, reusable modules or subroutines.
  • Use Constants: Define constants for frequently used values to make your code easier to update and maintain.
  • Error Handling: Implement error handling to gracefully manage unexpected situations, such as invalid inputs or failed operations.

Conclusion

Integer variables are a powerful feature in Mini Mouse Macro, enabling you to create sophisticated and dynamic automations. By understanding how to define, manipulate, and evaluate integer variables, you can significantly enhance the capabilities of your macros. Remember to follow best practices, such as using descriptive names, initializing variables, and testing thoroughly, to create robust and maintainable automations. With the knowledge gained from this guide, you are well-equipped to leverage the full potential of integer variables in your Mini Mouse Macro projects.

Further Exploration

This guide has covered the essentials of integer 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, and GOTO, 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.

⬆️ Back to Top