# Finding a Pixel Color

## Recommended Posts

Well, I need a function or something that allows me to find the pixel color of something on the screen. The X and Y coordinates of this pixel are random, so how would I just be able to grab a pixel color from a random place? If someone could please post back here with an answer I would be very grateful. Thanks

##### Share on other sites

Take a look at:

Random - To randomly look for a pixel

Ubound - Return the size for random

PixelGetColor - To get the pixel colour

MouseGetPos - For mouse

##### Share on other sites

Ahh, should I look for those in the Function documentation? Thankies

Yes.

Anytime.

##### Share on other sites

Hmm, I still need some more help on this topic. I can't figure out how to get those all to work together. I know it's easy, but I can't grasp it...

##### Share on other sites

Hmm, I still need some more help on this topic. I can't figure out how to get those all to work together. I know it's easy, but I can't grasp it...

When you say " The X and Y coordinates of this pixel are random, "

Is there a specific color that moves randomly around the screen that you are trying to find? If so, then you answer is "PixelSearch()"

But to grab A random pixel color from anywhere on your desktop, try something like this:

```\$x = Random( 0, @DesktopWidth,1) ;Random number between 0 and the width of your desktop (in pixels)
\$y = Random( 0, @DesktopHeight,1) ;Same as above, just with height

\$color = PixelGetColor(\$x,\$y) ;gets the color of the X,Y Coords and sets "\$color" to it
Msgbox(0,"Random Color Finder", "Random Coordinate: ("&\$x&", "&\$y&")"&@CRLF&"Color (Dec): "&\$Color&@CRLF&"Color (Hex): 0x"&Hex(\$Color))```

EDIT: btw, I am unable to test atm, but i am pretty confident that it will have no errors. I'm at work

Edited by Paulie

## Create an account

Register a new account