pixel
Returns a colour component of one pixel on the screen.
Keyboard Maestro: PIXEL
Details #
pixel(component, x, y) takes exactly three arguments and returns a number.
x and y are screen coordinates in points from the top left of the main screen. component (not case-sensitive) is one of:
| component | range |
|---|---|
red (or r), green (or g), blue (or b) (or b) | 0 to 255 |
hue (or h) | 0 to 360 |
saturation (or s), brightness (or v) | 0 to 100 |
alpha (or a) | 0 to 100 |
The colour is read in sRGB and rounded to a whole number.
Parameters #
Takes 3 arguments.
{{ pixel(text, b, c) }}
Examples #
pixel("red", 10, 10)→
0pixel("brightness", mouseX(), mouseY())→
0Gotchas #
Reads the screen, so it needs Screen Recording permission. If the pixel can't be read, or x and y aren't numbers, or the component is unknown, it returns 0, which is also a real answer for black, so check the permission before trusting a 0.
It captures one pixel each call; a loop over many pixels is slow.