AutoHotkey - "return" 和 "break" 之间不应该有区别吗?

AutoHotkey - Shouldn't there be a difference between "return" and "break"?

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

这里是有效的脚本:

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

这里我对前面的脚本做了一个函数,"Something went wrong!" 之后的 "return" 被解释为 "break" 命令似乎是因为在 msgbox 对话框之后 "Something went wrong!"我收到下一个消息框。

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
                }
        } 
    }

我在 AutoHotkey 上找到了解决方案。我必须在循环中使用 "exit" 而不是 "return" 。这就是诀窍!