<< Click to Display Table of Contents >> Navigation: 3. Script Language > Image/Pixel-Color Operations > Non-IR Operations > Image/Pixel-Color Operations |
MiniRobotLanguage (MRL)
IPC. / NPC. Conditional Statement
If Pixel Color
Intention
Conditional Statement. Test if a specified screen-pixel has a specified color or not. Useful in cases, where the window controls can not be accessed in any other way.
This command provides a lot of operation modes, to be as compatible as possible with changing desktop-themes, different video-cards etc. After all, this command should only be used as the last choice if nothing else will help you.
The reason is, that any dependency on pixel-colors may not work in cases of changing resolution, other dpi-settings or other video-cards or drivers.
Therefore it is recommended that you locate the pixel always window-relative instead of using screen coordinates. This is done if you specify the |o before the comma separated coordinates. In that case, the coordinates will be relative to the last located child- or top-window. Let's start with the very simple case of:
' Check if the colors will match exactly!
IPC.o|23,34|=$$COL
DBP.I am in here!
EIF.
You can use the = (equal) or the ! (unequal) operator to check an exact match of colors.
IPC.[o]|x,y|Formula
IPC.o|23,34|=COL ' equal
IPC.o|23,34|!COL ' unequal
In real life, white is not always white (&HFFFFFF). And black is not always really black (&H0). There need to be tolerances. They are implemented using the w (RGB<5) and the b (RGB>252) operators.
IPC.o|23,34|=w ' Is white
IPC.o|23,34|=b ' Is Black
IPC.o|23,34|=!w ' Is not white
IPC.o|23,34|=!b ' not black
Sometimes, you just need to know if a color is lighter or darker then another color. This is done by adding the RGB values and comparing the results.
IPC.o|23,34|<COL ' dunkler als COLOR
IPC.o|23,34|>COL ' heller als COLOR
Many times, we are only interested if the red, green or blue part of a color is lighter or darker then a reference. Often that is a better indicator then the overall color. For these cases you can just add a letter:
IPC.o|23,34|=[rgb]COL
IPC.o|23,34|<[rgb]COL ' dunkler als COLOR
IPC.o|23,34|>[rgb]COL ' heller als COLOR
which would look like these example:
' weniger rot als COLOR
IPC.o|23,34|<r$$COL
DBP.less red in here!
EIF.
' mehr grün als COLOR
IPC.o|23,34|>g$$COL
DBP.More green in here!
EIF.
But now its gets even more compatible and interesting. To eliminate the problems i have told you above, there are more options.
' max. difference in % for r,g and b
' here we choose 20% max. difference
IPC.o|23,34|~$$COL,20
' max. difference in % for r,g and b
' here we choose 15% max. difference
IPC.o|23,34|~rgb$$COL,15
' max. difference in % for r and g
' here we choose 20% max. difference
IPC.o|23,34|~rg$$COL,20
' max. difference in % for r only
' here we choose 20% max. difference
IPC.o|23,34|~r$$COL,20
' max. difference in % for g only
' here we choose 20% max. difference
IPC.o|23,34|~g$$COL,20
' max. difference in % for g and b
' here we choose 7% max. difference
IPC.o|23,34|~gb$$COL,7
' max. difference in % for r and b
' here we choose 10% max. difference
IPC.o|23,34|~rb$$COL,10
Now we come to a very unique feature of IPC. It knows the system-colors of the actual system, its running on! You can find a table with the numbers of the system colors below "Parameters". As you can see, Nr.15 is:
15 = Face color for three-dimensional display elements and
for dialog box backgrounds.
Now we can use these system colors directly with IPC, and NPC. using the "s" prefix. Here is an example, that checks if the button is there. It checks if the point has the system color it should have at this place. This is a large step ahead to make IPC. more usable even in Software distribution. Because using the "s" prefix, it can adapt to individual system colors!
STW.t|testap
SCW.ct|button|1
' Prüfen ob Farbwert mehr als 10% abweicht
IPC.o|116,38|s15
MBX.$$CNT-$$000
EIF.
END.
For usage in browser-windows, take a look at the possibility of
' choose if the pixel is white or not
IPC.o|x,y,|!w
The color of the specified pixel is always placed on the actual stack. The ~ Operator can be used to check if a color is near - but not exact a given value.
This helps to make automations more compatible using different graphics-cards.
Negative form of this command is NPC.
Syntax
IPC.[P1]|P2|P3|P4 ELS. … EIF.
Parameter Explanation
P1 - (optional) can be:
r - do relative Movement from actual point
c - use child-coordinates
o - use coordinates from actual window whatever
t - use actual top-window coordinates
s - screen coordinates (default if omitted)
P2 - Variable[Operator]Variable
P3 - Options:
If Parameter "sxx" is used, there are 30 possible system-colors which can be used to compare with the found pixel-color. Value B for Black or W for white is also possible.
Please use the numeric value instead of the "xx" in "sxx".
0 = Scroll bar gray area.
1 = Desktop-color
2 = Active window title bar. Also specifies the left side
color in the color gradient of an active window's title
bar if the gradient effect is enabled.
3 = Inactive window caption. Also specifies the left side color
in the color gradient of an inactive window's title bar if
the gradient effect is enabled.
4 = Menu/Messagebox background.
5 = Window and Button background.
6 = Window frame.
7 = Text in menus and Messageboxes.
8 = Text in windows.
9 = Text in caption, size box, and scroll bar arrow box.
10 = Active window border.
11 = Inactive window border.
12 = Background color of multiple document
interface (MDI) applications.
13 = Item(s) selected in a control.
14 = Text of item(s) selected in a control.
15 = Face color for three-dimensional display elements and
for dialog box backgrounds.
16 = Shadow color for three-dimensional display elements
(for edges facing away from the light source).
17 = Grayed (disabled) text. This color is set to 0
if the current display driver does not support
a solid gray color.
18 = Text on push buttons.
19 = Color of text in an inactive caption.
20 = Highlight color for three-dimensional display elements
(for edges facing the light source.)
21 = Dark shadow for three-dimensional display elements.
22 = Light color for three-dimensional display elements
(for edges facing the light source.)
23 = Text color for tooltip controls.
24 = Background color for tooltip controls.
26 = Color for a hyperlink or hot-tracked item.
27 = Right side color in the color gradient of an active
window's title bar. Nr.2 specifies the left side color.
28 = Right side color in the color gradient of an
inactive window's title bar. Nr. 3 specifies the
left side color.
29 = The color used to highlight menu items when the menu
appears as a flat menu. The highlighted menu item is
outlined with Nr.13.
30 = The background color for the menu bar when menus appear
as flat menus. Anyway Nr.4 continues to specify the
background color of menu popups.
You can see the system color of the pixel, below the mouse cursor in the windows-analyzer.
P4 - Value*
IPC's can be nested to unlimited Depth, and they can also enclose Sub-Programm Calls or FEX. (Enumerations) to unlimited Depth.
Formats:
' IPC.[o]|x,y|Formula
' IPC.o|23,34|=COL ' EUQAL
' IPC.o|23,34|!COL ' NOT EQUAL
' IPC.o|23,34|=w ' ' Is white (R,G and B each > 252)
' IPC.o|23,34|=b ' ' Is black (R,G and B each < 5)
' IPC.o|23,34|!w ' ' Is not white (R,G and B each < 253)
' IPC.o|23,34|!b ' ' Is not black (R,G and B each > 4)
' IPC.o|23,34|<COL ' darker then COLOR
' IPC.o|23,34|>COL ' lighter then COLOR
' This version compares color with actual system colors
' IPC.o|23,34|sxx ' xx stands for a number from 0 to 30
' You can check the r or g or b part only
' IPC.o|23,34|=[rgb]COL
' IPC.o|23,34|<[rgb]COL ' r/g/b darker then COLOR
' IPC.o|23,34|>[rgb]COL ' R/g/b lighter then COLOR
' You can check for a maximum difference in %
' where 100% is 255
'
' IPC.o|23,34|~COL,Zahl 'max. difference in % for r,g and b
' IPC.o|23,34|~rgbCOL,Zahl 'max. difference in % for r,g and b
' IPC.o|23,34|~rgCOL,Zahl 'max. difference in % for r and g
' IPC.o|23,34|~rCOL,Zahl 'max. difference in % for r only
' IPC.o|23,34|~gCOL,Zahl 'max. difference in % for g only
' IPC.o|23,34|~gbCOL,Zahl 'max. difference in % for g and b
' IPC.o|23,34|~rbCOL,Zahl 'max. difference in % for r and b
Example
'**********************************************
' IPC-Sample
'**********************************************
' DBM.2
PRT.START
JNF.Move-Console.txt
STW.ct|ieframe|internet
VAR.§§COR=274,334
MMV.§§COR
'-------------------------
GPC.
PRT.Colour is: $$000
'-------------------------
IPC.#ixp#,#iyp#|=&H08000
PRT.IS-1
ELS.
PRT. IS NOT
EIF.
'-------------------------
IPC.274,334|=&H08000
PRT.IS-2
ELS.
PRT. IS NOT
EIF.
'-------------------------
IPC.§§COR|=&H08000
PRT.IS-3
ELS.
PRT. IS NOT
EIF.
'-------------------------
' Darker then
IPC.§§COR|<&H09000
PRT.IS-4
ELS.
PRT. IS NOT
EIF.
'-------------------------
' lighter then
IPC.§§COR|>&H07000
PRT.IS-5
ELS.
PRT. IS NOT
EIF.
'-------------------------
' Red-part lighter then
IPC.§§COR|=r&H07000
PRT.IS-6
ELS.
PRT. IS NOT
EIF.
'-------------------------
' Green-Part lighter then
IPC.§§COR|>g&H07000
PRT.IS-7
ELS.
PRT. IS NOT
EIF.
'-------------------------
' Compare a button-color with the system-colors
' This is an example for the "sxx"
STW.t|sample ap
SCW.ct|button|1
FOR.$$CNT|0|30
IPC.o|10,10|s$$CNT
PRT.$$CNT
EIF.
NEX.
'-------------------------
' Compare a button-color with the system-colors for background
' This is an example for the "sxx"
STW.t|sample ap
SCW.ct|button|1
IPC.o|10,10|s5
PRT.Button hat bei 10,10 Hintergrundfarbe
EIF.
NEX.
'-------------------------
' Example for the ~ (Tilde)Operator
' Check if Pixelcolor is near to the given Reference
STW.t|sample ap
SCW.ct|button|1
' 15790320 = F0F0F0
VAR.$$CNT=&HF0F0AA
' We allow 10% difference
IPC.o|10,10|~$$CNT,10
MBX.Reference color: $$CNT $crlf$ Found color: $$000
EIF.
END.
'-------------------------
END.
Remarks
Limitations:
Color-Values Nr. 29 and 30 are not supported below Windows XP.-
See also: