为什么命令不能在SetTimer之后运行?

问题描述 投票:2回答:1

此代码显示消息框:

Msgbox, Hello

SetTimer, CheckTime, 1000 ; updates every 1 second
CheckTime:
Return

但这不是:

SetTimer, CheckTime, 1000 ; updates every 1 second
CheckTime:
Return

Msgbox, Hello

这是为什么?我没有看到SetTimer命令有什么特别之处。

timer autohotkey
1个回答
2
投票

只要找到第一个Return关键字,脚本就会停止执行新行。

第一个顶级Return之后的所有内容将在初始执行时被忽略,除非它已从上面的行调用。

看看这段代码:

MsgBox, I'll run!!!

MsgBox, Me 2!!!

Gosub, PastReturn

overPastReturn()

MsgBox, Me 5!!!

Return ; This is the first Top Level Return. Code Stops Executing Here.

MsgBox, Not Me!!!

PastReturn:
    MsgBox, Me 3!!!
Return ; This Return Belongs to PastReturn Label.

MsgBox, Not Me 2!!!

overPastReturn(){
    MsgBox, Me 4!!!
}
© www.soinside.com 2019 - 2024. All rights reserved.