Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 自动热键-x27;“有什么区别吗?”;return";及;打破;?_Function_Loops_Return_Autohotkey_Break - Fatal编程技术网

Function 自动热键-x27;“有什么区别吗?”;return";及;打破;?

Function 自动热键-x27;“有什么区别吗?”;return";及;打破;?,function,loops,return,autohotkey,break,Function,Loops,Return,Autohotkey,Break,在下面的脚本中,我在循环中使用了“return”和“break”,但两者的效果相同。他们所做的是打破循环,继续脚本的其余部分。但是,在返回之后,脚本不应该继续,我的意思是,这就是break命令的作用,对吗?中断循环并继续执行脚本。返回后,脚本不应继续:?: 下面是一个有效的脚本: F1 & i:: start := A_TickCount Loop { ImageSearch, FoundX, FoundY, 0, 0, A_Scr

在下面的脚本中,我在循环中使用了“return”和“break”,但两者的效果相同。他们所做的是打破循环,继续脚本的其余部分。但是,在返回之后,脚本不应该继续,我的意思是,这就是break命令的作用,对吗?中断循环并继续执行脚本。返回后,脚本不应继续:?:

下面是一个有效的脚本:

F1 & i::
        start := A_TickCount
        Loop {
            ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, G:\Saves\AutoHotkey - Snipping Tool - Screenshots\Chrome - New Tab.png
            totalTime := stop - start
            stop := A_TickCount
            if ErrorLevel = 0
                {
                break
                }
            else if totalTime > 3000
                {
                MsgBox, Something went wrong!
                return
                }
        } 
                msgbox, This message box should only appear when the immage was found!
                return
在这里,我对前面的脚本做了一个函数,“出错了!”之后的“return”被解释为“break”命令,这似乎是因为在msgbox对话框“出错了!”之后,我得到了下一个msgbox

F1 & i::
ImageSearchFunction("G:\Saves\AutoHotkey - Snipping Tool - Screenshots\Chrome - New Tab.png")
msgbox, This message box should only appear when the immage was found!
return
这里是函数本身:

ImageSearchFunction(ImagePath){
        start := A_TickCount
        Loop {
            ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %ImagePath%
            totalTime := stop - start
            stop := A_TickCount
            if ErrorLevel = 0
                {
                break
                }
            else if totalTime > 3000
                {
                MsgBox, Something went wrong!
                return
                }
        } 
    }

我在自动热键上找到了解决方案。我必须在循环中使用“exit”而不是“return”。这就是诀窍