SetTimer
與腳本的其餘部分並行運行其任務,這就是爲什麼你沒有看到循環等待。
你可以包括計時器內循環,這將迫使它等待循環完成其任務,前打破,如下面的代碼:
DoTheLoop()
{
StartTime := A_TickCount ; Set current tick time (uptime of PC) to compare against.
loop
{
ElapsedTime := A_TickCount - StartTime ; Difference between start of loop and now.
SendInput, %ElapsedTime%{Enter}
Sleep, 1000
if (ElapsedTime >= 10000) ; 10.0 sec.
{
break
}
}}
Home::
SetTimer, skillbuffs
skillbuffs:
DoTheLoop()
SendInput, Skillbuffs timer has fired.{Enter}
SetTimer, skillbuffs, On
return
但是,這充其量是個雜牌,因此不是100%可靠的。除此之外,如果你有明確定義的任務和時間表,你似乎在過度設計這個問題。
相反,我會建議去簡單:
MainLoop()
{
StartTime := A_TickCount ; Set current tick time (uptime of PC) to compare against.
loop
{
ElapsedTime := A_TickCount - StartTime ; Difference between start of loop and now.
; Do stuff in the loop.
if (ElapsedTime >= 60000) ; 60.0 sec.
{
SendInput, {F5} ; Press self skill every 60 sec.
StartTime := A_TickCount ; Reset StartTime variable.
}
}}
Home::
MainLoop()
return
目前尚不清楚你的要求。使用您當前的代碼,計時器將每分鐘運行一次,然後「主」循環將繼續運行。 – Oleg