Temptive moving perimeter scan

Post your working scripts, libraries and tools
Posts: 73
Joined: 26 Jan 2018, 19:54

Temptive moving perimeter scan

19 Oct 2018, 23:34

I'm pretty sure there's better ways to achieve the same goal;
I tried breadcrumbrling with the perimeter color and it worked weomewhat well, but if anyone would like to try and expand on this, and maybe correct where I went wrong I'd appreciate.
It freezes at around 359 degrees, and increasingly skips at 180.
In concept, it is somehow able to follow a moving, variable perimeter by estimating it's center position.
So, here it is:
#SingleInstance, force
#MaxThreadsperHotkey 2
SysGet, Monitor2, Monitor, 2
CoordMode, Pixel
CoordMode, Mouse
SetBatchLines, 10
SetDefaultMouseSpeed, 0
SetKeyDelay, 0, 0
SetMouseDelay, 0
SetWorkingDir A_ScriptDir
SetFormat, FloatFast, 0.3
RCtrl & F10:: Reload
RCtrl & F11:: Pause
RCtrl & F12:: ExitApp
MouseGetPos, X0, Y0
;msgbox %X0%, %Y0%
PixelSearch, PerimeterX0, PerimeterY0, X0, Y0, 2*A_ScreenWidth, Y0 + 1, 0xFF2C2C,, Fast RGB
If ErrorLevel
MsgBox, That color was not found in the specified region.
Else {
Radius:= PerimeterX0 - X0
n:= 0
Cycles:= 0
Degrees:= n
Radians:= n * 0.0174533
RadiusCos0:= Radius * Cos(Radians)
RadiusSin0:= Radius * Sin(Radians)
Loop {
Radians:= n * 0.0174533
Xn:= X%n%
Yn:= Y%n%
RadiusCos%A_Index%:= Radius * Cos(Radians)
RadiusSin%A_Index%:= Radius * Sin(Radians)
RadiusCosA_Index:= RadiusCos%A_Index%
RadiusSinA_Index:= RadiusSin%A_Index%
ScanX%A_Index%:= Xn + RadiusSinA_Index
ScanY%A_Index%:= Yn - RadiusCosA_Index
ScanXA_Index:= ScanX%A_Index%
ScanYA_Index:= ScanY%A_Index%
PixelSearch, PerimeterXA_Index, PerimeterYA_Index, ScanXA_Index - 45, ScanYA_Index - 45, ScanXA_Index + 45, ScanYA_Index + 45, 0xFF2C2C,, Fast RGB
If (ErrorLevel = 0) {
MouseMove, PerimeterXA_Index, PerimeterYA_Index
X%n%:= PerimeterXA_Index - RadiusSinA_Index
Y%n%:= PerimeterYA_Index + RadiusCosA_Index
Xn:= X%n%
Yn:= Y%n%
MovX%A_Index%:= PerimeterXA_Index - ScanXA_Index
MovY%A_Index%:= PerimeterYA_Index - ScanYA_Index
MovXA_Index:= MovX%A_Index%
MovYA_Index:= MovY%A_Index%
X%A_Index%:= Xn - MovXA_Index
Y%A_Index%:= Yn - MovYA_Index
XA_Index:= X%A_Index%
YA_Index:= Y%A_Index%
;Msgbox XA_Index %XA_Index%, YA_Index %YA_Index%, MovXA_Index %MovXA_Index%, MovYA_Index %MovYA_Index%, Xn %Xn%, Yn %Yn%, RadiusCosA_Index %RadiusCosA_Index%, RadiusSinA_Index %RadiusSinA_Index%, ScanXA_Index %ScanXA_Index%, ScanYA_Index %ScanYA_Index%`n`rn Degrees %n%, A_Index %A_Index%
If (ErrorLevel = 1) {
PartialTurnCount:= n/360
PartialTurn:= Round (PartialTurnCount, 2)
MsgBox, Out of Bounds, %Cycles% cycles, %PartialTurn% PartialTurns, %n% degrees, %A_Index% iterations
n+= 1
If (n > 359) {
n:= 0
Cycles+= 1

Best regards;

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 63 guests