String Variables in Mini Mouse Macro
Table of Contents
Introduction
String variables store text that can be reused throughout a macro. They are useful for filenames, messages, labels, OCR text, generated commands, and any other value that needs to be treated as text instead of math.
You can use built-in names such as %STRING% and %STRING1%, or define custom names such as %FileName%, %Greeting%, or %ErrorMessage%.
Defining String Variables
Use RUN ACTION | DEFINE STRING VARIABLE to assign or update a string value.
Basic assignment
1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::StartMacro1
2 | RUN ACTION | DEFINE STRING VARIABLE | %Name%::Sam
3 | RUN ACTION | DEFINE STRING VARIABLE | %City%::Sydney
Each example stores the text to the right of :: in the named variable.
Plain values act as SET
If you provide plain text first, Mini Mouse Macro treats it as a SET operation:
1 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello
2 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello::APPEND:: world
Line 2 is interpreted as:
SET helloAPPEND world
String Operations
RUN ACTION | DEFINE STRING VARIABLE supports stacked string operations. This lets you build or modify a string in several steps within one action.
Supported operations
SET::<value>APPEND::<value>PREPEND::<value>CLEARREPLACE::<old>::<new>INSERT::<index>::<value>REMOVE::<start>REMOVE::<start>::<count>SUBSTRING::<start>SUBSTRING::<start>::<count>TRIMTRIMSTARTTRIMENDUPPERLOWERPADLEFT::<width>PADLEFT::<width>::<char>PADRIGHT::<width>PADRIGHT::<width>::<char>
Examples
1 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello::APPEND:: world
2 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::APPEND::!
3 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::PREPEND::Say:
4 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::REPLACE::world::MMM
5 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::TRIM::UPPER
6 | RUN ACTION | DEFINE STRING VARIABLE | %Label%::SET:: abc ::TRIM::INSERT::1::-::SUBSTRING::0::4::PADRIGHT::6::.
These examples demonstrate that you can:
- build a value in multiple steps
- apply operations to the current value without resetting it first
- chain several operations in one action
The last example produces a-bc...
Where these operations are used
The operations in this section apply when you use:
RUN ACTION | DEFINE STRING VARIABLE
Other string features in Mini Mouse Macro use their own formats. For example:
IF | STRING VARIABLE | ...- non-action variable assignment paths
- read-side helper expressions such as
%VAR%.tolower
Parsing Rules
SET consumes text until the next recognized operation
1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::SET::hello::world
This stores the literal text hello::world.
Operation-only expressions work against the current value
1 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello
2 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::APPEND:: world
After line 2, %Greeting% contains hello world.
Missing required arguments fail
Operations such as REPLACE, INSERT, REMOVE, SUBSTRING, PADLEFT, and PADRIGHT require the expected number of arguments. If part of the command is missing, Mini Mouse Macro does not guess what you meant.
Variables Inside String Operations
When you use variables inside a string operation, Mini Mouse Macro resolves their values when the action runs. This lets the same action produce different results as your variables change.
Example
1 | RUN ACTION | DEFINE STRING VARIABLE | %Summary%::%A%::APPEND:: ::APPEND::%B%::LOWER
If %A% resolves to Hello and %B% resolves to World, the final value becomes hello world.
Repeated expressions
If the same string-building action runs repeatedly, such as inside a loop, it uses the current values of your variables each time it runs.
Numeric Arguments and Padding
Some string operations expect numeric values:
INSERTREMOVESUBSTRINGPADLEFTPADRIGHT
Additional padding rules:
PADLEFTandPADRIGHTdefault to a space when no pad character is supplied.- If the pad-character value resolves to more than one character, only the first character is used.
String Comparisons in IF Statements
String variables are also used in conditions.
Supported comparison operators
ISIS NOTCONTAINS
Examples
1 | IF | STRING VARIABLE | %Mode% | IS | StartMacro1 | RUN ACTION | DEFINE STRING VARIABLE | %Mode%::Macro1Process
2 | IF NOT | STRING VARIABLE | %Response% | IS | Yes | RUN ACTION | MESSAGE PROMPT | Please answer Yes::Error
3 | IF | STRING VARIABLE | %FileName% | CONTAINS | Report | RUN ACTION | DEFINE STRING VARIABLE | %FilePath%::D:\Reports\%FileName%
These comparisons use their own condition format.
String Output
String variables can be inserted into prompts, typed output, filenames, and other action parameters.
Examples
1 | RUN ACTION | DEFINE STRING VARIABLE | %FileName%::Report_%RANDOM_1-999%
2 | RUN ACTION | MESSAGE PROMPT | Current file: %FileName%::Info
3 | 2409 | 790 | 200 | Keypress My string variable is equal to %FileName%
Best Practices
- Use descriptive names for strings with a clear business purpose.
- Use stacked operations when one action needs to build or normalize text in several steps.
- Prefer explicit
SETwhen you want the operation sequence to be obvious to a reader. - Use the formats on this page with
RUN ACTION | DEFINE STRING VARIABLE.