Pixel - Image Search Scripting Aid / Test Environment

Post your working scripts, libraries and tools
Hellbent
Posts: 143
Joined: 23 Sep 2017, 13:34

Pixel - Image Search Scripting Aid / Test Environment

18 Nov 2017, 21:08

Hey what is going on folks.

A few weeks ago I did a tutorial series on Pixel search and for the tutorials I made a script aid sort of deal to give users a mock environment to build up and test out their scripts. Well now that I am done with it, I thought some of you might find it helpful when working on scripts that use pixel search or Image search.
The script is easy to set up and use and you can do most of your script testing using it rather than perhaps having to load this or that, or wait for condition x to happen blah, blah, blah.

There are two modes, one is a stationary target that jumps to a new random location when it is clicked, and the other is a moving target.
Although this was made with pixel search in mind, it should be very, very, very easy to change it to image search.

I am sure that as soon as you run it you will figure out how to adjust the settings, but if you have questions just ask.

https://pastebin.com/isUzqYcv

Code: Select all

#SingleInstance,Force
OnMessage(0x201,"Check_Hit")
global Rad1:=,Rad2:=,Speed:=1,THWND:=,Target1:=,Click_Count:=0,Target:={}
BackGround_Color:="ffffff",Target.x:=20,Target.y:=40,Target.w:=15,Target.h:=15,Target_Width:=Target.w
Target_Height:=Target.h,Target.Color:="22aaff",Target.Dir:=2,Target.Timer:=0
Gui,1: +OwnDialogs ;+AlwaysOnTop
Gui,1:Color,Black,Black
Gui,1:Font,cRed s22 Bold Q4
Gui,1:Add,Text, x10 y5 w680 Center vClick_Count,Count: %Click_Count%
Gui,1:Font,
Gui,1:Add,Progress,x20 y40 w660 h330 Background%BackGround_Color% vThe_BackGround
Gui,1:Add,Progress,% "x" Target.x " y"Target.y " w" Target.w " h" Target.h " Background" Target.Color " vTarget1",
GuiControlGet,THwnd,HWND,Target1
Gui,1:Add,Groupbox,cTeal x20 y385 w120 h100 ,Mode
Gui,1:Add,Radio,cLime x35 y415 Checked vRad1 gSubmit_All,Click Mode
Gui,1:Add,Radio,cLime x35 yp+25 vRad2 gSubmit_All,Move Mode
Gui,1:Add,Groupbox,cTeal x160 y385 w520 h100 ,Options
Gui,1:Add,Text,cLime x175 y410 ,Target Color:
Gui,1:Add,Edit,cWhite x+5 yp-2 w80 h20 Center vNew_Target_Color gSubmit_All,% Target.Color
Gui,1:Add,Text,cLime x+20 yp+2 ,Target Speed:
Gui,1:Add,Edit,cWhite x+5 yp-2 w80 h20 Center Number vSpeed gSubmit_All,% Speed
Gui,1:Add,Text,cLime x+20 yp+2 ,Target Width:
Gui,1:Add,Edit,cWhite x+5 yp-2 w80 h20 Center Number vTarget_Width gSubmit_All,% Target.w
Gui,1:Add,Text,cLime x175 y450 ,Background Color:
Gui,1:Add,Edit,cWhite x+5 yp-2 w80 h20 Center vNew_BackGround_Color gSubmit_All,% BackGround_Color
Gui,1:Add,Text,cLime x+20 yp+2 ,Target Height:
Gui,1:Add,Edit,cWhite x+5 yp-2 w80 h20 Center Number vTarget_Height gSubmit_All,% Target.h
Gui,1:Add,Button,x+20 w131 h20 gReload ,Reload
Gui,1:Show,w700 h500,Target
Gui,1:Submit,NoHide
return
GuiClose:
	ExitApp
Reload:
	Reload
Submit_All:
	Gui,1:Submit,NoHide
	if(Rad2=1)
		SetTimer,Move_Target,10
	else
		SetTimer,Move_Target,Off
	GuiControl,1: +Background%New_Target_Color%,Target1
	GuiControl,1: +Background%New_BackGround_Color%,The_BackGround
	GuiControl,1:Move,Target1,w%Target_Width% h%Target_Height%
	Target.w:=Target_Width
	Target.h:=Target_Height
	return
Move_Target:
	Target.Timer++
	if(Target.Timer>30)
		{
			Random,Dir,1,4
			Target.Dir:=Dir
			Target.Timer:=0		
		}
	if(Target.x<20)
			Target.Dir:=2
	else if(Target.x>(680-Target.w))
			Target.Dir:=4
	else if(Target.y<40)
			Target.Dir:=3
	else if(Target.y>(370-Target.h))
			Target.Dir:=1			
	if(Target.Dir=1)
			Target.y-=Speed
	else if(Target.Dir=2)
			Target.x+=Speed
	else if(Target.Dir=3)
			Target.y+=Speed
	else if(Target.Dir=4)
			Target.x-=Speed
	GuiControl,1:Move,Target1,% "x" Target.x " y" Target.y
	return
Check_Hit()
	{
		if(Rad1=1)
			{
				mouseGetPos,,,,c1,2
				if(C1==THwnd)
					{
						Click_Count++
						GuiControl,1:,Click_Count,% "Count: " Click_Count
						Max_X:=680-Target.w
						Random,x,20,Max_X
						Target.x:=x
						Max_Y:=370-Target.h
						Random,y,40,Max_y
						Target.y:=y
						GuiControl,1:Move,Target1,% "x" Target.x " y" Target.y
					}
			}		
		else if(rad2=1)
			{
				mouseGetPos,,,,c1,2
				if(C1==THwnd)
					{
						Click_Count++
						GuiControl,1:,Click_Count,% "Count: " Click_Count
					}
			}		
	}
*^Numpad1::ExitApp

Return to “Scripts and Functions”

Who is online

Users browsing this forum: aseiot, B1z2, DRocks, Gangrel, Google [Bot] and 32 guests