PixelSearch 6-colors simultaneously

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Galaxis
Posts: 73
Joined: 04 Feb 2016, 20:09

PixelSearch 6-colors simultaneously

02 May 2017, 15:50

I wrote this script to search different colors simultaneously, but the mouse isn't moving. The colors must all be present, within a given area before mouse movement is executed. But my mouse isn't moving. Am I writing this correctly?
The script runs, without error messages, and yet the mouse does not move. Its just weird. What revisions needs to be made? Mouse moves to correct coordinates w/ the 2 colors. However, when I hit 3 colors- the script runs, but the mouse is unresponsive. Please advise, thanks...

Code: Select all

PixelExist(x1,y1, x2, y2, Color)
{

	PixelSearch, X, Y, %x1%, %y1%, %x2%, %y2%, %Color%,  3, Fast
	if ErrorLevel
	{
		X := -1
		Y := -1
	}
	zone := [X, Y]
	return zone
}

$1::
	XStart := 0
	YStart := 0
	theObgectFound := false
	
	while(theObgectFound = false)
	{
		zone := PixelExist(0, YStart, A_ScreenWidth, A_ScreenHeight, "0xFFFFFF") ;RED
		if(zone[1] != -1)
		{
			
			Xblack1 := zone[1]                          ; <<BLACK coordinates>>
			Yblack1 := zone[2]
			Xblack2 := Xblack1 + 30
			Yblack2 := Yblack1 + 30


			zone1 := PixelExist(Xblack1, Yblack1, Xblack2, Yblack2, "0x000000") ;BLACK
		    if(zone1[1] != -1)
	        {
		        Xorange1 := Xblack2 - 30                 ; <<ORANGE coordinates>>
			    Yorange1 := Yblack2 + 30
			    Xorange2 := Xorange1 + 30
			    Yorange2 := Yorange1 + 30

			 
			    zone2 := PixelExist(Xorange1, Yorange1, Xorange2, Yorange2, "0x277FFF") ;ORANGE
			    if(zone2[1] != -1)
			    {	
		           Xpurple1 := Xorange2 - 30              ; PURPLE coordinates>>
			       Ypurple1 := Yorange2 - 30                
			       Xpurple2 := Xpurple1 + 30
			       Ypurple2 := Ypurple1 + 30
				   
			
			        zone3 := PixelExist(Xpurple1, Ypurple1, Xpurple2, Ypurple2, "0xA449A3") ;PURPLE
			        if(zone3[1] != -1)
			        {
		                Xblue1 := Xpurple2 + 30              ; BLUE coordinates>>
			            Yblue1 := Ypurple2 - 30                
			            Xblue2 := Xpurple1 + 30
			            Yblue2 := Ypurple1 + 30
	                  
	
			         zone4 := PixelExist(Xgreen1, Yblue1, Xblue2, Yblue2, "0xCC483F") ;BLUE
			         if(zone4[1] != -1)
			           {
		                 Xgreen1 := Xpurple2 - 30            ; GREEN coordinates>>
			             Ygreen1 := Ygreen2 - 30                
			             Xgreen2 := Xgreen1 + 30
			             Ygreen2 := Ygreen1 + 30
			
			
			              zone5 := PixelExist(Xgreen1, Ygreen1, Xgreen2, Ygreen2, "0x4CB122") ;GREEN
			              if(zone5[1] != -1)
			             {
				          MouseMove, %Xblack1%, %Yblack1%
				           theObgectFound := true
				         }
		          	       else
			             {  
	
	
			         	 YStart := Yblack1 + 10
	

                         
       
	
	    
	
	
                          
                    }   }
        	}   }
		}
	}
	
}
	
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Marium0505, mcl and 349 guests