如何将在 1 个图像搜索循环中找到的所有 X、Y 位置保存到不同的变量?

How to save all X,Y positions found in 1 image search loop to different variables?

如何将一个图像搜索循环中找到的所有X、Y位置保存到不同的变量?

我的图像循环搜索找到了随机数量的黄色方块(这次是 3 个方块,有时更多)。它右键单击一个黄色方块,然后该方块消失(这有助于立即找到下一个方块)。它再次右键单击一个,依此类推。当找不到更多方块(它们一个接一个地消失)时,它会打破循环。

有效,但如何将找到的所有 3 个位置保存为 3 个不同的变量(稍后调用)?我可以不用循环,但我需要循环。

我正在使用 feiyue's FINDTEXT function 并且无法更改开头的代码:

    #Include <FindText>
    z::
    ;;; this is just my initial search of two images to set up my search range which works well.
    
    Text:="|<wcBL_c95>0x0D0D0D@0.95.VV8GUI0A0s1U1E+EYADzk"
    if (ok:=FindText(aX, aY, 0, 0, 1918, 1078, 0, 0, Text))
    
    Text:="|<wcTR_c95>0x0D0D0D@0.95.zy64V+1E0k3U6050d2Ekk"
    if (ok:=FindText(bX, bY, 0, 0, 1918, 1078, 0, 0, Text))
    
    ;;;===> The above 4 lines search for the coordinates on my screen to look at. You can ignore this part, but this gives me the coordinates RANGE to do my loop search in as seen below: aX, bY, bX, aY

 Loop
   {
    Text:="|<wc\_c100>0xD9D4D4@1.00.SzzzzSU"
    
    if (ok:=FindText(VarX, VarY, aX+11, bY, bX-11, ay, 0, 0, Text))
    
    {
        MouseClick, Right, X, Y, 1, 1  ; This loop finds 3 Sqaures. 
         VarX1:= % X
         VarY1:= % Y   ;  how do I increment these for the next loops?
    }
else break      
}

MouseMove, VarX1, VarY1, 1

sleep, 333

MouseMove, VarX2, VarY2, 1  ;  Doesn't exist (i need to increment varibales in the loop - HELP!)

sleep, 333

MouseMove, VarX3, VarY3, 1  ; Doesn't exist (i need to increment varibales in the loop - HELP!)

Return

在分配“x”和“y”值时,您可以只在变量中使用 %A_Index%:

if (ok:=FindText(VarX, VarY, aX+11, bY, bX-11, ay, 0, 0, Text)) {

    MouseClick, Right, X, Y, 1, 1 
    VarX%A_Index%:= X
    VarY%A_Index%:= Y
}

这是一个例子:

x= 10
Loop, 10 { 

    x++
    y--

    VarX%A_Index%   := X
    VarY%A_Index%   := Y  
}
    
MsgBox  %   VarX1       "`t"    VarY1       "`n"
        .   VarX2       "`t"    VarY2       "`n"
        .   VarX3       "`t"    VarY3       "`n"
        .   VarX4       "`t"    VarY4       "`n"
        .   VarX5       "`t"    VarY5       "`n"
        .   VarX6       "`t"    VarY6       "`n"
        .   VarX7       "`t"    VarY7       "`n"
        .   VarX8       "`t"    VarY8       "`n"
        .   VarX9       "`t"    VarY9       "`n"
        .   VarX10      "`t"    VarY10