check for pixel color on a region

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

check for pixel color on a region

20 Jul 2018, 02:38

Hi,

I'm still pretty new at AutoHotkey.

I would like to check if a region on (specified by 4 coordinates) has specific solid pixel color (white in this case).

I know how to check on a color of a specific pixel, but not on a region.

Is anybody able who can help me?

Example what I want to do:
if (region = white) then
press space bar
else
press enter key
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: check for pixel color on a region

20 Jul 2018, 03:43

if u wanna check if a region contains a pixel of a specified color use PixelSearch
if u wanna check if the entirety of a region is of a specified color u figure out its width and height, set up 2 nested loops and check each pixel within, individually, using PixelGetColor or other means(gdip_getlockbitpixel)
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

Re: check for pixel color on a region

20 Jul 2018, 07:09

Hi,
I have updated the code a little, so that I only check on a horizontal line of pixels;

I have created this code, for testing purposes:

Code: Select all

^j::

	x:= 800
	while (x <= 810)
	{
	pixelGetColor, pColor, x, 500
	if (pColor == FFFFFF)
		{
		Msgbox, white text detected!
		break
		}
	x:= x +1
	}
Msgbox, Done!
however, I can't get the messagebox popup "white space detected", which I would expect on a completely white screen,
although I am sure the screen is white.

Anyone can help me?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: check for pixel color on a region

20 Jul 2018, 08:23

FFFFFF in the context of your if-statement is an unitialized variable, and not a hexadecimal number. u need:

Code: Select all

if (color = 0xFFFFFF)
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

Re: check for pixel color on a region

20 Jul 2018, 10:51

swagfag wrote:FFFFFF in the context of your if-statement is an unitialized variable, and not a hexadecimal number. u need:

Code: Select all

if (color = 0xFFFFFF)
that worked. Thanks!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, dangoscrub, Google [Bot], joedf, Nerafius and 148 guests