Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > Non-IR Operations >

Image/Pixel-Color Operations

WLC. - Wait for Line Color

Previous Top Next


MiniRobotLanguage (MRL)

 

WLC. Wait Statement

Wait for Line Color

 

 

Intention

 

Wait for Condition Statement.

 

Wait until an defined Color is been found along a defined Line.

 

Or, Wait until colors along a given line do not match a defined color.

This is done using the "!" Operator.

 

Important: Color-Operations are often troublesome because colors may not match exactly. Therefore this command provides you with a "Color Tolerance" Option.

Also you have the choice of using a "negative version" which will just check that colors do NOT match a given color/tolerance. And you can combine all this, with the resolution independent SPR 3.6 Using Quadrant-Coordinates to make your Scripts run as compatible as possible.

 

Parameter 1 - Line-Coordinates:

The Line is defined by a Start- and and Endpoint. Using the following Format:

 

WLC.x1,y1,x2,y2

 

Its best practice to always use window local coordinates. For this specify a small "w" just in front of the coordinates.

 

WLC.wx1,y1,x2,y2

 

As always, if you omit y2 then y2 is assumed to be equal to y1.

Also, you can simplify many tasks, by just using 3.6 Using Quadrant-Coordinates.

In this case do not specify the "w" as the Quadrants are always window local.

 

If you omit the coordinates, the last located window or other object-rectangle is been taken, and the line goes from the upper-left to the lower-right corner.

 

General Usage is as simple as:

 

STW.ct|MyClassName|Sample Application

'SCW.nct|1|Edit|{&NOTEXT:}

' Wait for Color "Black" (&H00) to appear inside the textbox

WLC.|&H00|0|4|60

DMP.6

MBX.!

ENR.

 

The five parameters are line-coordinates, Color, Color-Tolerance and Hit-Counter and Timeout in Seconds.

 

Parameter 2 - Color:

 

If this color is found along the defined Line then the decision will switch to "true".

Colors can most easily be described as a HEX-Number, like this example:

 

&HFFEE22

&HRRGGBB

 

If you prefix the color-parameter with a "!"  (NOT Operator) then the command will count all Pixels that do NOT have that defined color and tolerance.

 

 

Parameter 3 -  Color Tolerance:

 

If there are different  graphic cards used, the pixels may not become rendered always in the exactly same way. Therefore the color tolerance gives you the chance to tell the robot "How sensitive" he should be when deciding if a pixel is different or not.

To make this decision, the robot will take the color of both pixels and calculate their "Color distance", that is "How similar the colors are". As a result he will get a number that can vary from 0 to 441673. Next Smart Package Robot  will get your tolerance value and check if the calculated color distance is inside the chosen tolerance or not.

 

Parameter 4 -  Hits-Counter:

 

Imagine a Textbox like this:

 

graphic

 

You want to wait until there is a text inside, but the blinking cursor should not make your Script react. Now what you tell Smart Package Robot  is a "Hit Count" of lets say 12 Pixels.

 

This Script will switch, after you really typed "88888888" into the first, left textbox.

 

STW.ct|MyClassName|Sample Application

SCW.nct|1|Edit|{&NOTEXT:}

MMV.

WLC.|&H000|1|15|60

DMP.6

MBX.!

ENR.

 

graphic

 

This makes Smart Package Robot  count the changed pixels, and only if she gets more then "Hit Count" she will switch. Otherwise the condition will not become true, even if there are changed pixels (but less).

 

In case of success, WLC. will leave four values on the stack. As you can see below, these are:

 

TOS: X-Position of first found Hit

001: Y-Position of first found Hit

002: Color of first found Hit

003: Number of found Pixel meeting the condition

 

graphic

 

 

 

The "negative Mode" using the "!" NOT Operator

 

Instead of counting the Pixels that do have a defined color, you can also do the opposite.

You can count the Pixel that do NOT have that defined color.

This is done, by prefixing the "Color-Parameter" with a !.

Like in this example.

 

STW.ct|MyClassName|Sample Application

SCW.nct|1|Edit|{&NOTEXT:}

MMV.

WLC.|!&HFFFFFF|1|15|60

DMP.6

MBX.!

ENR.

 

 

 

 

Syntax

 

WLC.[w][P1][|P2][|P3][|P4][|P5]

 

 

Parameter Explanation

 

P1 - (optional) Start and End-Points of the Line.

There are different possible Formats for these Coordinates.

        With out the leading "w", these are Screen-Coordinates.

   Its best practice, to prefer Child-Window-relative coordinates:

   WLC.w18,56,153,57|$$COL|$$TOL

 

You can simply specify the start and end-point. In this format:

WLC.x1,y1,x2,y2

         a real example would be:

        WLC.10,15,100,200

        Or you can specify a Rectangle, using Numbers like:

        WLC.10,15,100

        then y2 is assumed to be the same as y1.

 

        You can also use 3.6 Using Quadrant-Coordinates.

        In this case the Line will be drawn from the upper-left corner straight to the lower right corner.

        WLC.{D1,D2}|$$COL|$$TOL|$$TIM

   WLC.{B1}|$$COL|$$TOL

 

       In the same way you can unse the large letter "W" or "C" and write:

ILC.W|$$COL|$$TOL|$$TIM

    ILC.C|$$COL|$$TOL

 

 If omitted the Rectangle from the last localized Object or window is taken, same as "W".

 

P2 - (optional) numeric/variable contains the color value to scan for.

 

P3 - (optional) numeric/variable contains the Tolerance to be used when checking if a color is different. You can specify the color tolerance as a numeric value  from  0 - 441673, or you can specify a percentage from 0% to 100%. If you specify a percentage, just add the % Sign after the number. The color tolerance is the maximum allowed Color-Distance between two colors. The maximum color distance is 441673 that is the distance between black and white. If you omit this parameter, the system will use a zero Tolerance. In this case the colors are just "equal or not equal".

 

P4 - (optional) numeric/variable contains the minimum number of "Hits" that are pixels that have to be different to make the decision to become "true".

 

P5 - (optional) numeric/variable contains the timeout time in seconds. After this time, the command will set the timeout-flag and just let the script go on running. You can ask for the state of the timeout-flag to find out, if a timeout happened or not.

 

 

 

 

Example

 

'***********************************

' WLC.-Sample

'***********************************

' Use "Sample Application"

'

STW.ct|MyClassName|Sample Application

SCW.nct|1|Edit|{&NOTEXT:}

MMV.

WLC.|&H000|1|15|60

DMP.6

MBX.!

ENR.

 

 

'***********************************

' WLC.-Sample

'***********************************

' Use "Sample Application"

'

STW.ct|MyClassName|Sample Application

SCW.nct|1|Edit|{&NOTEXT:}

MMV.

WLC.|!&H0FFFFFF|1|15|60

DMP.6

MBX.!

ENR.

 

 

 

Remarks

 

-

 

 

 

Limitations:

 

-

 

 

 

 

See also:

 

    ! Smart Package Robot 's Pixel-Operations

    1.8.1 The "Client" and the "Non-Client" Parts of a window

    3.6 Using Quadrant-Coordinates

    IPC. / NPC. - If-Pixel-Colour

    GPC. - Get-Pixel-Colour

    ILC. / NLC. - If Line Color

    RRA. - Remember Rectangular Area

    IRA. / NRA. - If Rect altered

    WRA. - Wait Rect-Area Altered