我的 ahk 代码不工作
My ahk code not working
F1::pause,toggle
F2::
Loop,
{
PixelSearch, Px, Py, 432, 298, 444, 286, 0xFFEB63, 3, Fast
if (errorlevel = 0)
{
Sleep 5000
Click 1040,638
Sleep 1500
Click 1055,288
Sleep 10000
}
else{
sleep 3000
Click 1136, 642
sleep 10000
}
}
当我按F2的时候应该在area.If里面搜索0xFFEB63 color 没有然后点击1136,642.At最起码是我想要的do.It直接跳转到else部分。
如果在指定区域找到颜色,ErrorLevel 设置为 0;如果未找到颜色,则设置为 1;如果存在阻止命令执行搜索的问题,则设置为 2。
https://autohotkey.com/docs/commands/PixelSearch.htm#ErrorLevel
F2::
Loop,
{
PixelSearch, Px, Py, 432, 298, 444, 286, 0xFFEB63, 3, Fast
if (errorlevel = 0) ; If color is found in the first area
{
Sleep 5000
Click 1040,638
Sleep 1500
Click 1055,288
Sleep 10000
}
else
if (errorlevel = 1) ; If color is not in the first area
{
sleep 3000
Click 1136, 642
sleep 10000
}
; else ; if (errorlevel = 2)
; do sth else
}
return
编辑:
你应该使用
CoordMode, Pixel, Screen
在自动执行部分,除非您希望坐标相对于活动 window。
F1::pause,toggle
F2::
Loop,
{
PixelSearch, Px, Py, 432, 298, 444, 286, 0xFFEB63, 3, Fast
if (errorlevel = 0)
{
Sleep 5000
Click 1040,638
Sleep 1500
Click 1055,288
Sleep 10000
}
else{
sleep 3000
Click 1136, 642
sleep 10000
}
}
当我按F2的时候应该在area.If里面搜索0xFFEB63 color 没有然后点击1136,642.At最起码是我想要的do.It直接跳转到else部分。
如果在指定区域找到颜色,ErrorLevel 设置为 0;如果未找到颜色,则设置为 1;如果存在阻止命令执行搜索的问题,则设置为 2。 https://autohotkey.com/docs/commands/PixelSearch.htm#ErrorLevel
F2::
Loop,
{
PixelSearch, Px, Py, 432, 298, 444, 286, 0xFFEB63, 3, Fast
if (errorlevel = 0) ; If color is found in the first area
{
Sleep 5000
Click 1040,638
Sleep 1500
Click 1055,288
Sleep 10000
}
else
if (errorlevel = 1) ; If color is not in the first area
{
sleep 3000
Click 1136, 642
sleep 10000
}
; else ; if (errorlevel = 2)
; do sth else
}
return
编辑: 你应该使用
CoordMode, Pixel, Screen
在自动执行部分,除非您希望坐标相对于活动 window。