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 #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
color | text | Yes | The colour to compare with, for example #FF8800. | |
x | any value | Yes | Horizontal position in screen points. Accepts a number or {{ }}. | |
y | any value | Yes | Vertical position in screen points. | |
compare | one of | is brighter darker moreRed lessRed moreGreen lessGreen moreBlue lessBlue | is (default), brighter, darker, moreRed, lessRed, moreGreen, lessGreen, moreBlue or lessBlue. | |
fuzz | any value | For is: how far off, in percent per channel, still counts. Default 0. | ||
sample | yes / no | Used only in a dry run: the pretend answer. Default true. |
Examples #
- If the pixel at (5, 5) is darker than #808080
- Show “Darker than mid grey”
- Else
- Show “Mid grey or lighter”
Gotchas #
In a dry run nothing is read: the condition passes with
sample(defaulttrue) and the trace sayssimulated.Needs both
xandy(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
fuzzrather than expecting an exact match.