ahk错误其他没有匹配if,what&#39?s错误?

时间:2017-09-11 20:40:37

标签: autohotkey

我的autohotkey脚本似乎是错的,但我仔细检查括号,我认为没关系,但我一直得到错误,否则没有匹配,如果,有什么我错过了吗?

    loot1()
{
    ImageSearch,violetX, violetY, 266, 141, 579, 527, C:\image\loot.png
    If ErrorLevel  {
    mobs1()    
}
    else If ErrorLevel=0 {

            mousemove(%violetX%,%violetY%)
            mouseclick, left
            return
    }
    else 
    {
        sleep, 100
            return
    }
}

1 个答案:

答案 0 :(得分:0)

您应该只使用If,因为之前的Else if没有与if (condition1) { // executed only if "condition1" equals true } else if (condition2) { // executed only if "condition1" was false and "condition2" equals true } else { // executed only if both "condition1" and "condition3" equals false } 匹配。

示例:

loot1()
{
    ImageSearch,violetX, violetY, 266, 141, 579, 527, C:\image\loot.png
    If ErrorLevel  
    {
    mobs1()    
    }
    else If ErrorLevel=0 
    {
        mousemove(%violetX%,%violetY%)
        mouseclick, left
        return
    }
    else 
    {
        sleep, 100
        return
    }
}

编辑,也许这是正确答案:

{{1}}

缺少括号,您应该缩进代码以获得更好的可视化效果。