PixelGetColor

Retrieves the color of the pixel at the specified x,y screen coordinates.

PixelGetColor, OutputVar, X, Y [, RGB]

 

Parameters

OutputVar The name of the variable in which to store the color ID in hexadecimal blue-green-red (BGR) format. For example, the color purple is defined 0x800080 because it has an 80 intensity for its blue and red components but a 00 intensity for its green component.
X, Y The X and Y coordinates of the pixel, which can be expressions. Coordinates are relative to the active window unless CoordMode was used to change that.
RGB If this parameter is the word RGB, the color will be retrieved in RGB vs. BGR format. In other words, the red and the blue components are swapped. This is useful for retrieving colors compatible with WinSet, Gui, Progress, and SplashImage.

 

ErrorLevel

ErrorLevel is set to 1 if there was a problem or 0 otherwise.

 

Remarks

The pixel must be visible; in other words, it is not possible to retrieve the pixel color of a window hidden behind another window. By contrast, pixels beneath the mouse cursor can usually be detected. The exception to this is game cursors, which in most cases will hide any pixels beneath them.

Use Window Spy (available in tray icon menu) or the example below to determine the colors currently on the screen.

 

Related

PixelSearch, ImageSearch, CoordMode, MouseGetPos

 

Example

^!z::
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
MsgBox, The color at the current cursor position is %color%.
return