boiler wrote: ↑11 Aug 2019, 15:03
The reason is that you have a "Break" inside the
If block which causes it to cycle to the next color and find that it's not there, and it continues until it cycles around and gets to the found color again.
Ok, I understand that, but how do I get it to stop cycling true/false when colors 2-6 are found? If I do not use the break command at all the script will cycle like this for all of the colors, and when it is placed outside the
if or
else blocks only the first color is found while all the others fail but the cycling stops. Where would I put the break command if not in the
if block?
PS thanks for the
RGB &
ToolTip info
Code: Select all
#SingleInstance Force
Process, Priority, , Above Normal
SetControlDelay, -1
SetBatchLines, -1
SetWinDelay, -1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen
MouseMove, (A_ScreenWidth/2), (A_ScreenHeight/2)
IfNotExist, %USERPROFILE%\Downloads\Testerpic2.jpg
{ UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=7788, %USERPROFILE%\Downloads\Testerpic2.jpg
SoundBeep, 300, 50
} SplashImage, %USERPROFILE%\Downloads\Testerpic2.jpg, B FS18, Teast Image
Loop, ;#1
{ LFColors := "0xED1B24|0x23B14D|0x3F47CC|0xFEF200|0x000000|0xFFFFFF"
; ( Red | Green | Blue | Yellow | Black | White )
Loop, Parse, LFColors, `|
{ PixelSearch, X, Y, X1, Y1, X2, Y2, A_LoopField, 0, Fast RGB
If (!ErrorLevel)
{ FrameColor := "Lime"
GoSub, Box
PixelGetColor, Color, X, Y, RGB, Fast
ToolTip, Pixel Found In Box `n%Color% Under Pointer, (X-52), (Y+57), 1
;Break
} Else,
{ FrameColor := "Red"
GoSub, Box
PixelGetColor, Color, X, Y, RGB, Fast
ToolTip, Searching In Box `n%Color% Under Pointer, (X-58), (Y+57), 1
;Break
} ;Break
}
} Return
Box:
{ WinGetPos,,, WindowWidth, WindowHeight, %WinTitle%
MouseGetPos, X, Y
; Uupper Left Corner | Lower Right Corner
; Left Top | Right Bottom
X1 := (X-50), Y1 := (Y-50), X2 := (X+50), Y2 := (Y+50) ;Adjust The Size of The Search Area/Box.
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
~Esc::ExitApp
Essentially I want this loop
Code: Select all
Loop, ;#1
{ LFColors := "0xED1B24|0x23B14D|0x3F47CC|0xFEF200|0x000000|0xFFFFFF"
; ( Red | Green | Blue | Yellow | Black | White )
;GoSub, Box
Loop, Parse, LFColors, `|
{ PixelSearch, X, Y, X1, Y1, X2, Y2, A_LoopField, 0, Fast RGB
If (!ErrorLevel)
{ FrameColor := "Lime"
GoSub, Box
PixelGetColor, Color, X, Y, RGB, Fast
ToolTip, Pixel Found In Box `n%Color% Under Pointer, (X-52), (Y+57), 1
Break
} Else,
{ FrameColor := "Red"
GoSub, Box
PixelGetColor, Color, X, Y, RGB, Fast
ToolTip, Searching In Box `n%Color% Under Pointer, (X-58), (Y+57), 1
;Break
} ;Break
}
} Return
to run like this loop
Code: Select all
Loop, ;#2
{ PixelSearch, X, Y, X1, Y1, X2, Y2, 0xED1B24, 0, Fast RGB
If (!ErrorLevel)
{ GoSub, Found
} Else,
{ PixelSearch, X, Y, X1, Y1, X2, Y2, 0x23B14D, 0, Fast RGB
If (!ErrorLevel)
{ GoSub, Found
} Else,
{ PixelSearch, X, Y, X1, Y1, X2, Y2, 0x3F47CC, 0, Fast RGB
If (!ErrorLevel)
{ GoSub, Found
} Else,
{ PixelSearch, X, Y, X1, Y1, X2, Y2, 0xFEF200, 0, Fast RGB
If (!ErrorLevel)
{ GoSub, Found
} Else,
{ PixelSearch, X, Y, X1, Y1, X2, Y2, 0x000000, 0, Fast RGB
If (!ErrorLevel)
{ GoSub, Found
} Else,
{ PixelSearch, X, Y, X1, Y1, X2, Y2, 0xFFFFFF, 0, Fast RGB
If (!ErrorLevel)
{ GoSub, Found
} Else,
{ GoSub, Searching
} } } } } } } Return
Found:
{ FrameColor := "Lime"
GoSub, Box
PixelGetColor, Color, X, Y, RGB, Fast
ToolTip, Pixel Found In Box `n%Color% Under Pointer, (X-52), (Y+57), 1
} Return
Searching:
{ FrameColor := "Red"
GoSub, Box
PixelGetColor, Color, X, Y, RGB, Fast
ToolTip, Searching In Box `n%Color% Under Pointer, (X-58), (Y+57), 1
} Return