Loop: Sequential Pixelsearch's not working
Posted: 10 Apr 2024, 06:25
I have a loop with a number of sequential pixel searches but the loop does not proceed past the first pixelsearch and its actions. Once it has found the colour 000000, it repeatedly clicks at Bx By instead of going onto the next search. Here is my script:
Code: Select all
ALoop:
; click
pixelsearch, Bx, By, 200, 150, 1230, 720, 000000, 1, Fast RGB
if (ErrorLevel = 0)
{
Bx := Bx + rand_gaussian_NN(2,2)
By := By + rand_gaussian_NN(2,2)
Click, %Bx% %By% ;Click
Random, randsleep, 1000, 2500
Sleep randsleep ; Wait
return
}
else
{
; Exit the loop if color 1 is not found
MsgBox, Color 1 not found! Exiting loop.
ExitApp
}
; all
pixelsearch, Dx, Py, 200, 150, 1230, 720, B97A57, 1, Fast RGB
if (ErrorLevel = 0)
{
Dx := Dx + rand_gaussian_NN(2,2)
Dy := Dy + rand_gaussian_NN(2,2)
Click, %Dx% %Dy% ; all
Random, randsleep, 1000, 2500
Sleep randsleep ; Wait
return
}
;
pixelsearch, Wx, Wy, 200, 150, 1230, 720, ED1C24, 1, Fast RGB
if (ErrorLevel = 0)
{
Wx := Wx + rand_gaussian_NN(2,2)
Wy := Wy + rand_gaussian_NN(2,2)
Click, %Wx% %Wy% ; all
Random, randsleep, 1000, 2500
Sleep randsleep ; Wait
; close
send, esc
Random, randsleep, 1000, 2500
Sleep randsleep ; Wait
return
}
; click
pixelsearch, Rx, Ry, 200, 150, 1230, 720, FFAEC9, 1, Fast RGB
if (ErrorLevel = 0)
{
Rx := Rx + rand_gaussian_NN(2,2)
Ry := Ry + rand_gaussian_NN(2,2)
Click, %Rx% %Ry% ; click
Random, randsleep, 1000, 2500
Sleep randsleep ; Wait
send, space ; TEST
Random, randsleep, 1000, 1500
Sleep randsleep ; Wait
return
}
CallALoop() ; Set a new random interval for the next iteration
UpdateToolTip() ; Update the tooltip
Return