if else does not work

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Freedo
Posts: 1
Joined: 19 Jan 2022, 22:13

if else does not work

Post by Freedo » 19 Jan 2022, 22:31

Hello, I have a problem with this code, what happens is that the second condition else if does not work, the loop avoids this condition but not if and else. The color is fine and the position, I have checked several times.
I have tried all the ways to write condition if , but it doesn't work.

Code: Select all

Global gs = 9

!r::
gs = 2
return

!s::
ExitApp

!q::
gs = 1
Gosub, TR
return



TR:
while(gs = 1){
	
		PixelGetColor, color, 516, 426
		
		if % color = 0xBD8837 ; green , this condition does work
		{
			send, {a}
			sleep, 300
		}else if % color = 0x71CC2E ; blue, this condition does not work
		{
			send, {d}
			sleep, 300
		}else{ 				; this condition does work
			sleep, 1
		}
			
}

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: if else does not work

Post by boiler » 19 Jan 2022, 22:59

The syntax is:

Code: Select all

if (color = 0xBD8837)
Reference: If (expression)


By the way, your colors in BGR look swapped according to your comments. The blue one looks green and the green one looks blue. And it doesn't look like it's an RGB vs. BGR issue since one of them is orange in RGB -- neither green nor blue.

Post Reply

Return to “Ask for Help (v1)”