Page 1 of 1

if #IfWinActive 'xx' AND the pixel_color of this position is 123

Posted: 29 Dec 2017, 04:16
by partof
I want to apply several shortcuts to a IfWinActive condition plus a pixel color

I'm looking for something that would look like:

Code: Select all

If (WinActive ahk_exe abc.exe) and (PixelGetColor at  1359, 64 RGB is "0x85C78B")
^a::
msgbox yes
I know I could do that (bellow) but is there a shorter way?


Code: Select all

#IfWinActive ahk_exe abc.exe 
^a::
	PixelGetColor mycolor, 1359, 64 RGB 

	if (color_sync_button="0x85C78B")
		{
		; dont do anything 
		return
		}
	else 
		{
		msgbox yes
		return
		}
^b::
	PixelGetColor mycolor, 1359, 64 RGB 

	if (color_sync_button="0x85C78B")
		{
		; dont do anything 
		return
		}
	else 
		{
		msgbox yes
		return
		}
etc. 

Re: if #IfWinActive 'xx' AND the pixel_color of this position is 123  Topic is solved

Posted: 29 Dec 2017, 13:09
by noname
Maybe it helps using functions ,it depends on what you want to do .

example:

Code: Select all

#If  WinActive("ahk_exe abc.exe") and get_pixel(1359, 64,0x85C78B)
^a::
msgbox yes
return
#If

get_pixel(x,y,color){
PixelGetColor mycolor, x,y, RGB
if (mycolor=color)
return 1
else
return 0
}

Re: if #IfWinActive 'xx' AND the pixel_color of this position is 123

Posted: 29 Dec 2017, 15:26
by nadjibSoft
if your title is "my pge". and the pixel is:"0x85C78B"
___________________________________
pixelExist(color, X, Y)
{
;return true if the pixel exist, and false if alse
}
IfWinActive , Gumroad - Mozilla Firefox
{
if(pixelExist("0x85C78B", X, Y))
{
MsgBox, OK
}
}

if you want a help inter my profile

Re: if #IfWinActive 'xx' AND the pixel_color of this position is 123

Posted: 30 Dec 2017, 11:23
by partof
thank you very much for your help!

Re: if #IfWinActive 'xx' AND the pixel_color of this position is 123

Posted: 30 Dec 2017, 17:07
by partof
noname wrote:Maybe it helps using functions ,it depends on what you want to do
It's perfect thanks a lot! (I just understood how to build ahk function, I'm very happy!)