Prism.js Language Definition: mmm

Pixel Variables in Mini Mouse Macro: A Comprehensive Guide

Table of Contents
  1. Introduction
  2. Defining Pixel Range Variables
    1. Definition Methods
      1. From Screen Location
      2. From Image File
      3. Optional Parameters
    2. Defining Variables Graphically
  3. Pixel Range Variable Properties
  4. Pixel Variable Evaluations
    1. MATCHES Operator
      1. Example
      2. Example with Action
  5. Saving Pixel Ranges
    1. Example
  6. Further Exploration

Introduction

In Mini Mouse Macro, PIXEL VARIABLE objects provide a powerful way to interact with the visual elements on your screen. They allow you to capture, compare, and evaluate regions of pixels, enabling automations based on visual cues and changes.

This guide will explore pixel variables in detail, covering their definition, usage, properties, and practical examples.


Defining Pixel Range Variables

A pixel range variable in Mini Mouse Macro holds a captured bitmap image, representing a specific rectangular area on the screen or loaded from an image file.

You define pixel range variables using the DEFINE PIXEL RANGE VARIABLE action.

Definition Methods

From Screen Location

You can capture a region of the screen by specifying its coordinates and dimensions:

1 | RUN ACTION | DEFINE PIXEL RANGE VARIABLE | %PIXEL_RANGE%::At Location [X:22 Y:122 W:34 H:43]

This code defines a pixel range variable named %PIXEL_RANGE% that captures a rectangular area on the screen:

  • X: 22 (starting horizontal position)
  • Y: 122 (starting vertical position)
  • W: 34 (width of the captured region)
  • H: 43 (height of the captured region)

From Image File

You can also define a pixel range variable by loading a bitmap image from a file:

1 | RUN ACTION | DEFINE PIXEL RANGE VARIABLE | %Player_Icon%::From image C:\Macro\pics\Player_icon.bmp::Starting player icon

This code defines a pixel range variable named %Player_Icon% and loads the bitmap image from “C:\Macro\pics\Player_icon.bmp”. It also adds a comment, “Starting player icon”, to the macro line.

Optional Parameters

The DEFINE PIXEL RANGE VARIABLE action also supports optional parameters:

  • Saving the Image: You can save the captured pixel range as a bitmap (.bmp) file.
  • Adding a Comment: You can add a comment to the macro line for better readability.
2 | RUN ACTION | DEFINE PIXEL RANGE VARIABLE | %PLAYER_ICON%::At Location [X:200 Y:150 W:50 H:100]::save image to c:\macro\Player.bmp::Icon for player1

This code defines %PLAYER_ICON%, captures a region of the screen, saves the captured image to “c:\macro\Player.bmp”, and adds the comment “Icon for player1” to the macro line.

Defining Variables Graphically

You can also define pixel range variables graphically using the “Define Pixel Range” interface launched when adding the condition via the ‘add condition’ dialog, as shown below:

Define Pixel Range Interface
Define Pixel Range Graphical Interface

This interface allows you to visually select a region on the screen, load an image, and configure the parameters for defining the pixel range variable.

⬆️ Back to Top


Pixel Range Variable Properties

When a pixel range variable is defined, it holds the captured bitmap image and several properties that provide information about the captured region. You can access these properties using the following syntax:

  • %PIXEL_RANGE%: The internal pixel range array index number.
  • %PIXEL_RANGE.XPOS%: The starting X coordinate of the captured region.
  • %PIXEL_RANGE.YPOS%: The starting Y coordinate of the captured region.
  • %PIXEL_RANGE.WIDTH%: The width of the captured region.
  • %PIXEL_RANGE.HEIGHT%: The height of the captured region.
  • %PIXEL_RANGE.TIME%: The time the pixel range was defined.
  • %PIXEL_RANGE.DATE%: The date the pixel range was defined.

Example:

If %PIXEL_RANGE% is defined as in the first example above, its properties would be:

  • %PIXEL_RANGE%: 0 (assuming it’s the first pixel range variable defined)
  • %PIXEL_RANGE.XPOS%: 22
  • %PIXEL_RANGE.YPOS%: 122
  • %PIXEL_RANGE.WIDTH%: 34
  • %PIXEL_RANGE.HEIGHT%: 43
  • %PIXEL_RANGE.TIME%: The time the variable was defined (e.g., “6:49:02 AM”)
  • %PIXEL_RANGE.DATE%: The date the variable was defined (e.g., “7/17/2021”)

⬆️ Back to Top


Pixel Variable Evaluations

The primary use of pixel variables is to compare different pixel ranges to detect visual changes on the screen. You can use the PIXEL VARIABLE condition to evaluate the difference between two defined pixel range variables.

MATCHES Operator

The MATCHES operator checks if two pixel range variables have identical bitmap images.

Example

1 | IF | PIXEL VARIABLE | %BANNER_ORIGINAL% | MATCHES | %BANNER_NEW% | CONTINUE

This code compares two pixel range variables, %BANNER_ORIGINAL% and %BANNER_NEW%. If the captured pixel regions (bitmaps) are identical, the macro continues execution. Otherwise, the macro waits until the regions match before proceeding.

Example with Action

1 | IF | PIXEL VARIABLE | %BANNER_ORIGINAL% | MATCHES | %BANNER_NEW% | MESSAGE PROMPT | Pixel Range Match!

If the captured pixel regions (bitmaps) are identical a message prompt will display.

⬆️ Back to Top


Saving Pixel Ranges

You can save the bitmap image stored in a pixel range variable to a file using the PIXEL RANGE SAVE action.

Example

1 | RUN ACTION | PIXEL RANGE SAVE | From Variable %PIXEL_RANGE%::C:\Macro\pixel_range.bmp

This code saves the bitmap image from the %PIXEL_RANGE% variable to the file “C:\Macro\pixel_range.bmp”.

⬆️ Back to Top


Further Exploration

This guide has covered the essentials of pixel variables in Mini Mouse Macro. To further enhance your skills, consider exploring the following topics:

  • Decimal Variables: Learn about decimal variables for working with floating-point numbers.
  • String Variables: Explore string variables for handling text and character data.
  • Boolean Variables: Discover boolean variables for logical conditions and flow control.
  • Array Variables: Dive into array variables for working with collections of data.
  • 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