If - Pixel exists

Declaration

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

Related Topics   

Description

Determines if the specified pixels 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, by default, any If activity added to the Task Builder's Steps panel 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

 
PropertyTypeRequiredDefaultMarkupDescription
IfText (Options)YesPixel colors match
  • ACTION="match"
  • 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 PositionNumberYes(Empty)XPOS="36"Specifies the X coordinate of the pixels 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 PositionNumberYes(Empty)XPOS="360"Specifies the Y coordinate of the pixel 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.
ColorNumberYes(Empty)COLOR="13160660"

Specifies the colors 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 windowYes/NoNoYesRELATIVE="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 screenYes/NoNoNoRELATIVE="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:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

If pixels matches the ones specified, a message box displays the message "Pixels match." Otherwise, a message box will display "Pixels do not match."

Copy
<AMIF ACTIVITY="pixel_exists" XPOS="152,248" YPOS="313,404" COLOR="16777215,12570320" />
<AMSHOWDIALOG MESSAGE="Pixels match." />
<AMELSE />
<AMSHOWDIALOG MESSAGE="Pixels do not match." />
<AMIF ACTIVITY="end" />