Page 1 of 1

Autoscript PixelSearch aka [QUICKPIXEL]

Posted: 12 Jun 2018, 07:38
by Galaxis
While creating a GameBot, I got tired of writing a crap-ton of PixelSearch statements. So I wrote this script and decided to share it with you guys today. I call it "QUICKPIXEL". This script finds the matching color you have clicked. It then places the coordinates of the pixel inside of an Array & Associative Array.

The entire Array with all the clicked coordinates is displayed in tooltip. All of the Arrays/Functions/Expressions are written into a text file, as seen in the tooltip, for your convenience. Your tooltip is populated with each click, if the appropriate color is matched. You can remove the PixelGetColor parameters, and have it record the X,Y of any color you click. Your Tooltip will eventually look like the image below:

Image


Just Copy & Paste, the auto-written PixelSearches & IF statements from the files named PIXEL.txt and EXP.txt

note** All Coordinates, Expressions, Arrays will be deleted upon Reload and Reopening of script. Reload is set as F1


Hope you all ENJOY! Any feedback would be much appreciated

Code: Select all

#SingleInstance force
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
FileDelete, %A_ScriptDir%\PIXEL.txt
FileDelete, %A_ScriptDir%\EXP.txt

;KeyWait, Joy1, D T3   <KEY DOWN 3 Seconds>                
;KeyWait, Joy1, D        <KEY DOWN>
;KeyWait, Joy1, U        <KEY UP>



	X_:=[ ]
	Y_:= [ ]
	
Loop
	{	
		
		
		M:= GetKeyState("Lbutton")
		MouseGetPos, x, y
		PixelGetColor, Color, x, y
		
		
		If (M=1 && color=0x000000)
		{
			KeyWait, Lbutton, U
			
			
			;¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
			;_________________________________QUICKPIXEL_______________________________________________________________/
			
			i++
			u++
			
			X_.insert(i, x)
			Y_.insert(u, y)
			
			a:= x-1
			b:= y-1
			c:= x+1
			d:= y+1
			
			FileAppend , PixelSearch`, x%i% `, y%i%`, %a%`, %b%`, %c%`, %d%`, %color%`, Fast  `n, PIXEL.txt
			FileRead, SEARCH, PIXEL.txt
			
			;_____________________________________________________________________________________________________________________________________________________________________________________________/
			Tooltip % "<Click color BLACK>     CURRENT Color =" color  "`n `nARRAY:=[" X_.1 ", " Y_.1 ", " X_.2 ", " Y_.2 ", " X_.3 ", " Y_.3 ", " X_.4 ", " Y_.4 ", " X_.5 ","
			. Y_.5 ", " X_.6 ", " Y_.6 ", " X_.7 ", " Y_.7 ", " X_.8 ", " Y_.8 ", " X_.9 ", " Y_.9 ", " X_.10 ", " Y_.10 ", " X_.11 ", " Y_.11 ", " X_.12 ", " Y_.12 ", " X_.13 ", " Y_.13 ","
			. X_.14 ", " Y_.14 ", " X_.15 ", " Y_.15 ", " X_.16 ", " Y_.16 ", " X_.17 ", " Y_.17 ", " X_.18 ", " Y_.18 ", " X_.19 ", " Y_.20 ", " X_.20 "]" 
			. "`n `nPIXEL: `n---------------------------------------------------------------------`n" Search 
			;-------------------------ASSOCIATIVE ARRAY TOOLTIP------------------------------------------------------------------------------------------------------------------------------------
			
			. "`n Associative ARRAY" 
			. "`nArray:={A:" X_.1 ", B:"Y_.1 ", C:"X_.2 ", D:"Y_.2 ", E:"X_.3 ", F:" Y_.3 ", G:"X_.4 ", H:"Y_.4 ", I:"X_.5 ",J:"
			. Y_.5 ", K:"X_.6 ", L:"Y_.6 ", M:" X_.7 ", N:" Y_.7 ", O:" X_.8 "}" 
			
			;________________________________________________________________________________________________________________________________________________________________________________________________
			;-----------------------------EXPRESSION TOOLTIP---------------<NEW>--------------------------------------------------------------------------------------------------------------------------
			
			. "`n `nEXPRESSION `n"EXPRESSION, 0, 0
			
			If i=1
			{
				FileAppend , IF (X%i% != `"`") %A_space%, EXP.txt
				
			}
			else If  i!=1
			{	FileAppend , && (X%i% != `"`" ) %A_space% , EXP.txt
				
			}
			
			FileRead, EXPRESSION, EXP.txt
		}
		
	}
	
	
	RETURN





F1::
FileDelete, %A_ScriptDir%\Pixel.txt
FileDelete, %A_ScriptDir%\Exp.txt
Reload
return


esc::exitapp
return