Yes, if you put 60 colors in the array, it will find the first color then press Down once before it starts the loop again and looks for the next color, then it finds the second color then presses Down twice, and so on until it reaches the last color and it will find that and press Down 60 times. The command Send, {Down 20} sends the down key 20 times, which is why Send, {Down %A_Index%} sends Down the number of times equal to the value of A_Index. And A_Index is the built-in loop counter. Each loop (the inner one and the outer one) have their own version of A_Index, so one doesn't affect the other.Qplshakyz wrote: ↑ ah okay so since i have thenand in pixelsearch varies by 30 it still looks for all the color above but just moves by that number so do i have to add 60 colors since i want the script to move down by a maximum of 60 timesCode: Select all
Colors := [0xB83031, 0xB73435, 0xB13434, 0x9C3032, 0xB24144, 0x912B2D, 0x611817, 0x7D2A29, 0x641B17, 0xA31B1E, 0xAA2D2C, 0x71150E]
That code is both loops. It already contains both an outer loop and an inner loop. You don't put it inside another loop. See the comments in the code below:
Code: Select all
; put as many colors as you want in the array below and that will determine how many times the outer loop executes (once for each color)
Colors := [0xB83031, 0xB73435, 0xB13434, 0x9C3032, 0xB24144, 0x912B2D, 0x611817, 0x7D2A29, 0x641B17, 0xA31B1E, 0xAA2D2C, 0x71150E]
for Each, Color in Colors ; this is the outer loop. for each iteration of the loop, it selects the next color in the array
{
loop ; this is the inner loop. it keeps looping until the color is found
PixelSearch, Px, Py, 988, 227, 990, 229, Color, 30, Fast RGB
until !ErrorLevel ; this ends the inner loop when the color is found
Send, {Down %A_Index%} ; this sends {Down 1} the first time through the outer loop, then {Down 2} the second time, and so on
}