If - Pixel Exists

Declaration

<AMIF ACTIVITY="pixel_exists" ACTION="text (options)" XPOS="number" YPOS="number" COLOR="text">

Description:

Determines if the specified pixel(s) is (are) in the specified state and returns TRUE or FALSE depending on the outcome. If TRUE, the task will execute the block of steps immediately following this step up until an End if step is encountered. If FALSE, the block will be skipped and execution will proceed directly after the End if step (or if an Else step is encountered, the task will execute that block of steps instead, up until an End if step is encountered).

Note: All If activities must be followed at some point with an End if step to mark the end of the code block that is to be executed if the expression is true. For ease of use, any If activity added to the Steps pane of the task builder is always followed by an End if activity.

Practical Usage

Commonly used to check if a graphic or area of the screen matches (or stops matching) a "checksum" of pixel colors. Very useful for detecting subtle changes in a window's contents that cannot be measure by any other means. In visual mode, it is easy to create the checksum values, while in the properties of the action, simply move the mouse pointer around the target window while repeatedly pressing the INSERT key.

Parameters

General

Property

Type

Required

Default

Markup

Description

If

Text (Options)

Yes

Pixel(s) Matches

  1. ACTION="match"

  2. ACTION="differ"

Specifies the type of pixel check to be performed. The available options are:

  • Pixel colors match - The IF block will be executed if the pixels match the value entered in the X/Y position parameter.

  • Pixel colors don't match - The IF block will be executed if the pixels are different from the value entered in the X/Y position parameter.

X Position

Number

Yes

(Empty)

XPOS="36"

Specifies the X coordinate of the pixel(s) to watch for. To capture pixel coordinates, click the Add button, hover the mouse cursor over the desired area on the screen and press the INSERT key. Multiple pixels/color pairs may be specified.

Y Position

Number

Yes

(Empty)

XPOS="360"

Specifies the Y coordinate of the pixel(s) to watch for. To capture pixel coordinates, click the Add button, hover the mouse cursor over the desired area on the screen and press the INSERT key. Multiple pixels/color pairs may be specified.

Color

Number

Yes

(Empty)

COLOR="13160660"

Specifies the color(s) that the corresponding pixels specified in XPOS and YPOS should match. To capture pixel coordinates, click the Add button, hover the mouse cursor over the desired area on the screen and press the INSERT key. Multiple pixels/color pairs may be specified.

Coordinates relative to foreground window

Yes/No

No

Yes

RELATIVE="NO"

If enabled, pixel coordinates will be relative to the foreground window. If this parameter is selected, the Coordinates relative to screen parameter is ignored. This parameter is enabled by default.

Coordinates relative to screen

Yes/No

No

No

RELATIVE="NO"

If enabled, pixel coordinates will be relative to the size of the screen. If this parameter is selected, the Coordinates relative to foreground window parameter is ignored.

Description

Error Causes

On Error

Example

NOTE: The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description: If pixel(s) matches the one(s) specified, a message box displays the message "Pixels match." Otherwise, a message box will display ""Pixels do not match."

 

<AMIF XPOS="152,248" YPOS="313,404" COLOR="16777215,12570320">

     <AMSHOWDIALOG MESSAGE="Pixels match." />

<AMELSE />

     <AMSHOWDIALOG MESSAGE="Pixels do not match." />

</AMIF>