Prism.js Language Definition: mmm

String Variables in Mini Mouse Macro: A Comprehensive Guide

Table of Contents
  1. Introduction
  2. Defining String Variables
    1. Naming Conventions
    2. Definition Examples
      1. Defining with the Default Name
      2. Defining with Custom Names
      3. Alternative Syntax
  3. String Variable Evaluations and Operations
    1. Available Operators
    2. Examples
      1. Using the IS Operator
      2. Using the IS NOT Operator
      3. Using the CONTAINS Operator
      4. Combining with Integer Variables
  4. FOR Loop Variables
    1. Available FOR Loop Variables
    2. Examples
      1. Iterating Through Lines in a File
      2. Processing Files in a Directory
  5. Complex String Constructs and Variable Usage in Macro Entries
    1. Example: Dynamic Mouse Movement Macro
  6. String Output
    1. Examples
      1. Basic String Output
      2. Using Variables in File Operations
      3. Combining String and Integer Output
  7. Further Exploration

Introduction

In Mini Mouse Macro, STRING VARIABLE objects are used to store, manipulate, and evaluate text. They are fundamental for creating dynamic and interactive macros that can adapt to various situations based on textual data. This guide will delve into the intricacies of string variables, providing a comprehensive understanding of their definition, usage, and practical applications.


Defining String Variables

String variables in Mini Mouse Macro store sequences of characters, such as words, sentences, or any other textual information. They can be defined using the internal %STRING% name or any custom name you choose, allowing for greater flexibility and readability in your macros.

Naming Conventions

Just like with integer variables, it’s highly recommended to use descriptive names for your string variables. Instead of generic names like %STRING% or %STRING1%, choose names that clearly indicate the purpose or content of the string, such as %FileName%, %UserName%, or %ErrorMessage%.

Definition Examples

Defining with the Default Name

1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::StartMacro1

This line of code defines a string variable named %STRING% and assigns it the value “StartMacro1”.

Defining with Custom Names

1 | RUN ACTION | DEFINE STRING VARIABLE | %Name%::Kirstin
2 | RUN ACTION | DEFINE STRING VARIABLE | %Gender%::Female
3 | RUN ACTION | DEFINE STRING VARIABLE | %City%::Townsville

Here, we define three string variables with custom names:

  • %Name% is assigned the value “Kirstin”.
  • %Gender% is assigned the value “Female”.
  • %City% is assigned the value “Townsville”.

Alternative Syntax

1 | RUN ACTION | ValueTemplate::New Value

This will define the %ValueTemplate% variable with the value “New Value”

⬆️ Back to Top


String Variable Evaluations and Operations

String variables can be used in conditional statements to control the flow of your macros based on their content. Mini Mouse Macro provides several operators for evaluating string variables.

Available Operators

  • IS: Checks if a string variable exactly matches a specified value (case-sensitive).
  • IS NOT: Checks if a string variable does not exactly match a specified value (case-sensitive).
  • CONTAINS: Checks if a string variable contains a specified substring (case-sensitive).

Examples

Using the IS Operator

1 | IF | STRING VARIABLE | %STRING% | IS | StartMacro1 | DEFINE STRING VARIABLE | %STRING%::Macro1Process

This code checks if the %STRING% variable is exactly equal to “StartMacro1”. If it is, the %STRING% variable is redefined with the value “Macro1Process”.

Using the IS NOT Operator

1 | IF NOT | STRING VARIABLE | %Response% | IS | Yes | RUN ACTION | MESSAGE PROMPT | Please answer Yes::Error

This code checks if the %Response% variable is not equal to “Yes”. If it isn’t, a message prompt is displayed.

Using the CONTAINS Operator

1 | IF | STRING VARIABLE | %FileName% | CONTAINS | Report | RUN ACTION | DEFINE STRING VARIABLE | %FilePath%::D:\Reports\%FileName%

This code checks if the %FileName% variable contains the substring “Report”. If it does, the %FilePath% variable is defined with a path that includes the filename.

Combining with Integer Variables

1 | IF NOT | STRING VARIABLE | %STRING4% | CONTAINS | Macro1 | DEFINE INTEGER VARIABLE | %INTEGER1%::+5

This code checks if the %STRING4% variable does not contain the substring “Macro1”. If it doesn’t, the integer variable %INTEGER1% has 5 added to it.

⬆️ Back to Top


FOR Loop Variables

FOR loops in Mini Mouse Macro introduce several built-in string variables that provide information about the current iteration of the loop. These variables are particularly useful when working with files and lines of text.

Available FOR Loop Variables

  • %I%: The current iteration count.
  • %LINE%: The current line of text (in FOR EACH LINE loops).
  • %FILE%: The full path and name of the current file (in FOR EACH FILE loops).
  • %FILE.NAME%: The name of the current file.
  • %FILE.EXT%: The extension of the current file (e.g., “.txt”, “.rtf”).
  • %FILE.PATHROOT%: The root of the file path.
  • %FILE.PATH%: The file path without the file name.
  • %FILE.ACCESSTIME%: The last access time of the file.
  • %FILE.WRITETIME%: The last write time of the file.
  • %FILE.CREATIONTIME%: The creation time of the file.

Examples

Iterating Through Lines in a File

1 | FOR EACH LINE | %LINE% | IN FILE | C:\Data\Input.txt | MESSAGE PROMPT | Current line: %LINE%::Output

This code iterates through each line in the file “C:\Data\Input.txt” and displays each line in a message prompt.

Processing Files in a Directory

1 | FOR EACH FILE | %FILE% | IN DIRECTORY | C:\Documents | IF | STRING VARIABLE | %FILE.EXT% | IS | .txt | RUN ACTION | MESSAGE PROMPT | Processing: %FILE%::Info

This code iterates through each file in the “C:\Documents” directory. If a file has the extension “.txt”, a message prompt displays its name.

⬆️ Back to Top


Complex String Constructs and Variable Usage in Macro Entries

Variables can be used in various parts of a macro entry, including actions, conditions, and even within the parameters of commands. This allows for dynamic macro behavior based on the current values of variables.

Example: Dynamic Mouse Movement Macro

* | This simple macro moves the mouse X and Y pos incrementally 100 times.
1 | RUN ACTION | %STRING% | %INTEGER1%::0
2 | %INTEGER1% | %INTEGER1% | %INTEGER2% | %STRING1%
%STRING2%
%STRING3%

With the following variable definitions:

  • %STRING%: DEFINE INTEGER VARIABLE
  • %STRING1%: Mouse Movement
  • %STRING2%: 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::+1
  • %STRING3%: 4 | IF | INTEGER VARIABLE | %INTEGER1% | < | 100 | GOTO MACRO LINE | 3 | ELSE | 4 | RUN ACTION | MESSAGE PROMPT | Mouse Moved 100 times::END
  • %INTEGER1%: 0
  • %INTEGER2%: 50

In this example, the variables are used to construct a macro that moves the mouse incrementally. The %STRING% variable holds the action DEFINE INTEGER VARIABLE, and other variables control the loop and output messages.

⬆️ Back to Top


String Output

String variables can be used to output text, either through message prompts or by simulating keyboard input.

Examples

Basic String Output

1 | 2409 | 790 | 200 | Keypress My string variable is equal to %string%

This code simulates typing the text “My string variable is equal to “ followed by the value of the %STRING% variable at the specified mouse coordinates.

Using Variables in File Operations

1 | IF | FILE | D:\Macro\MMM_10.txt | EXIST | RUN VIA CMD /C | rename "D:\Macro\MMM_10.txt" "MMM_%string3%_%random_5-15%

This code renames a file if it exists. The new filename includes the value of the %STRING3% variable and a random number between 5 and 15.

Combining String and Integer Output

1 | 2739 | 701 | 200 | Keypress My integer is %INTEGER%. A random is: %random_1-100000% and here is my string:%string%

This code simulates typing a string that includes the values of an integer variable (%INTEGER%), a random number, and a string variable (%STRING%).

⬆️ Back to Top


Further Exploration

This guide has covered the essentials of string 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