AutoHotKey SetTimer 立即第一次迭代

AutoHotKey SetTimer immediate 1st iterration

如果我使用:

SetTimer, T1, 5000

T1:
    Send, {1 Down} {1 Up}
return

..它在 5 秒后运行第一次迭代。

有没有办法立即开始第一次迭代?

不,但您可以在启动计时器之前(或之后)Gosub(docs) 到标签:

Gosub, T1
SetTimer, T1, 5000

T1:
    Send, {1 Down} {1 Up}
return

或者,如果您想放弃旧版 AHK 并使用一个函数,您可以先调用该函数:

T1()
SetTimer, T1, 5000

T1()
{
    Send, {1 Down} {1 Up}
}

或者甚至称之为内联:
SetTimer, % ("T1", T1()), 5000

要添加到@0x464e 的答案中,您可以对 运行 执行以下操作一次,但立即在伪线程中进行。

SetTimer, T1, -1

SetTimer, T1, -0   ; this works, but I don't recommended it as it's not documented.

您可以在此处阅读有关 AutoHotkey 线程的更多信息:
https://www.autohotkey.com/docs/misc/Threads.htm