PixelSearch with visual cue

Post your working scripts, libraries and tools
User avatar
Posts: 149
Joined: 19 Dec 2015, 00:20

PixelSearch with visual cue

03 Dec 2019, 11:27

Here is a fun little script I made to help me understand PixelSearch a bit better. I thought it might help others as well.

Code: Select all

;<===================================== PixelSearch with visual cue =====================================>
#SingleInstance Force
PID := DllCall("GetCurrentProcessId") ;PID Of Script
Process, Priority, %PID%, Above Normal
SetControlDelay, -1
SetBatchLines, -1
SetWinDelay, -1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen
MouseMove, (A_ScreenWidth/2), (A_ScreenHeight/2)
BoxSize = 50	;Adjust The Size of The Search Area/Box.
IfNotExist, %USERPROFILE%\Downloads\Test_Pic.jpg
{	UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=8420, %USERPROFILE%\Downloads\Test_Pic.jpg
} SplashImage, %USERPROFILE%\Downloads\Test_Pic.jpg, B FS18, Teast Image
{	PixelSearch, X, Y, X1, Y1, X2, Y2, 0x000000, 0, RGB Fast
	If (!ErrorLevel)
	{	FrameColor := "Lime"
		GoSub, Box
		ToolTip, Pixel Found, (X-40), (Y+57), 1
	} Else,
	{	FrameColor := "Red"
		GoSub, Box
		ToolTip, Searching, (X-30), (Y+57), 1
}	} Return
{	WinGetPos,,, WindowWidth, WindowHeight, %WinTitle%
	MouseGetPos, X, Y
	;	Uupper Left Corner		|	Lower Right Corner
	;	Left		   Top		|	Right		Bottom
	X1 := (X-BoxSize), Y1 := (Y-BoxSize), X2 := (X+BoxSize), Y2 := (Y+BoxSize)
	FrameThickness := (1), FrameWidth := (X2-X1), FrameHeight := (Y2-Y1)
	Gui, 1: Margin, %FrameThickness%, %FrameThickness%
	Gui, 1: Color, %FrameColor%
	Gui, 1: Add, Text, W%FrameWidth% H%FrameHeight% 0x6
	Gui, 1: -Caption +AlwaysOnTop +ToolWindow +LastFound
	Gui, 1: Show, NoActivate, Gui1
	WinSet, TransColor, White
	WinMove, %WinTitle%,, (X-(WindowWidth/2)), (Y-(WindowHeight/2))
} Return
;<================================================= END =================================================>
Last edited by PipeDreams on 03 Dec 2019, 19:01, edited 1 time in total.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: hasantr and 26 guests