AHK 像素搜索循环
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
我正在尝试让我的 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