AHK PixelSearch Loop



我正在尝试让我的AHK脚本工作。基本上,我想找到一行x像素的颜色0x26FDFD(BGR(。但我不太了解AHK脚本语言,也不知道如何想出一种聪明、干净、简单的方法来编程该循环,即起点将根据上次找到的坐标进行修改。

然而,到目前为止,我得到的是:

SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79

;Farbe nach der gesucht wird:
ColorVar := 0x26FDFD
i:=0
while i < 10
{
PixelSearch, FoundX, FoundY, 0, 0, VirtualWidth, VirtualHeight, %ColorVar%, 3, Fast
if (ErrorLevel = 2)
{
MsgBox Could not conduct the search.
return
}
else if (ErrorLevel = 1)
{
MsgBox Color could not be found on the screen.
return
}
else
{
MouseMove, %FoundX%, %FoundY%
MsgBox Found a Pixel at %FoundX%x%FoundY%.
;return
}

i++
}

这是一个愚蠢而基本的问题,但不知怎么的,我想不通。

我只需要在每个循环的末尾存储X和Y坐标,然后相应地设置新的起点。

这是代码:

i:=0
while i < 5
{
PixelSearch, FoundX, FoundY, startX%A_Index%, startY%A_Index%, VirtualWidth, VirtualHeight, %ColorVar%, 3, Fast
Switch ErrorLevel
{
Case 1:
MsgBox Website ueberpruefen!
return
Case 2:
MsgBox Makro ueberpruefen!
return
Default:            
MouseMove, %FoundX%, %FoundY%
;MsgBox Found a Pixel at %FoundX%x%FoundY%.
nextLoop := A_Index + 1
startX%nextLoop% := FoundX + 1
startY%nextLoop% := FoundY
}

i++
}
;msgbox % "found 5 matches!, first at: " startX2 "x" startY2
return

最新更新