Browse the docs

Pixel colour

Passes when the colour of one screen pixel is a given colour, or brighter, darker or more or less red, green or blue than it.

The pixel at x, y is color

Keyboard Maestro: Pixel (Is, Is Brighter, Is Darker, Is More Red)

Details #

Reads the colour of the screen at x, y and compares it with color the way compare says. The default is passes when every channel is within fuzz percent of the colour you gave; 0 means exact.

The other comparisons look at one thing: brighter and darker compare the average of red, green and blue; moreRed, lessRed, moreGreen, lessGreen, moreBlue and lessBlue compare that one channel with the colour's. They are strict, so equal does not pass.

color is #RRGGBB or RRGGBB; three numbers such as 255 136 0 (or three between 0 and 1) also work. Coordinates are screen points from the top left. The trace shows the pixel found, the color wanted and the compare used.

Every condition accepts "negate": true, which flips the verdict. The trace records what was compared before the flip, so a negated condition that blocks a macro still shows the real values.

Conditions in an Only if list combine with all: every one must pass, and an empty list always passes. An if step or a repeat loop takes a match of all (default) or any.

Parameters #

ParameterTypeRequiredValuesWhat it does
colortextYesThe colour to compare with, for example #FF8800.
xany valueYesHorizontal position in screen points. Accepts a number or {{ }}.
yany valueYesVertical position in screen points.
compareone ofis brighter darker moreRed lessRed moreGreen lessGreen moreBlue lessBlueis (default), brighter, darker, moreRed, lessRed, moreGreen, lessGreen, moreBlue or lessBlue.
fuzzany valueFor is: how far off, in percent per channel, still counts. Default 0.
sampleyes / noUsed only in a dry run: the pretend answer. Default true.

Examples #

Is the top-left pixel dark
Do
  1. If the pixel at (5, 5) is darker than #808080
  2. Show “Darker than mid grey”
  3. Else
  4. Show “Mid grey or lighter”
Open in Switchboard to try it

Gotchas #

  • In a dry run nothing is read: the condition passes with sample (default true) and the trace says simulated.

  • Needs both x and y (pixelColor needs x and y) and a readable colour (pixelColor needs a colour like #FF8800).

  • Display colour profiles can change what a pixel reads as; use fuzz rather than expecting an exact match.

See also #