Need help to wait for a pixel color to change Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
marc873a
Posts: 37
Joined: 23 Jun 2020, 10:49

Need help to wait for a pixel color to change

23 Jun 2020, 11:09

Hi.
I tried to wrote a code to check for one pixel has the right color:

Code: Select all

Pxc1 = 0

Numpad1::
Loop {
PixelGetColor, Pxc1, 906, 284
if (%Pxc1% = 0xB0FEFF)
{
Msgbox, Pixel is now at the right color
Break
}
}
return


It doesn't work.
Plz explain if you do something sophisticated as I am kinda new to AHK.
Thanks
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Need help to wait for a pixel color to change  Topic is solved

23 Jun 2020, 11:35

No % symbols around Pxc1 in the if statement. Also, if 0xB0FEFF is in RGB format (as opposed to BGR), then you need to specify the RGB option in the PixelGetColor command. Or you could specify the color as 0xFFFEB0.
slechtwere
Posts: 6
Joined: 23 Jun 2020, 05:01

Re: Need help to wait for a pixel color to change

23 Jun 2020, 14:02

Code: Select all

Numpad1::
Pxc1 = 0

Loop {
	PixelGetColor, Pxc1, 906, 284, RGB

	;if Pxc1% = 0xB0FEFF
    	if Pxc1 = 0xFF0000
		{
		Msgbox, 4096, , Pixel is now at the right color
		Break
		}
}
return
This works. I have used pure red (FF0000) because I think it's a good way to test the script. Your colour is commented out here.
That's how I found out I have to put 'RGB' in the PixelGetColor code. Because if it was BGR (default) my FF0000 would be pure blue.

I also suggest to look at your coordinates for the pixel, because default it's in the Active Window. Use Window Spy or the command MouseGetPos to find your exact x and y.

I don't know why (also a beginner) the MsgBox in your code was only very shortly visible and it dissapeared to the background.
MsgBox option 4096 is to keep it on top.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo, Bing [Bot] and 150 guests