如何在不阻挡其他标签的情况下在多个标签上使用WinWait?

时间:2016-09-15 14:20:31

标签: autohotkey

SetTimers指向多个标签,但当其中一个标签中有WinWait时,它们就会停止工作。

SetTimer, MyLoop, -5
SetTimer, MyLabel, -1000
Return

MyLoop:
    SoundBeep, 700
    SetTimer, MyLoop, -5
Return

MyLabel:
    SoundBeep, 300
    WinWait, Notepad
    SetTimer, MyLabel, -1000
Return
MyLoop到达MyLabel部分后,

WinWait停止工作。如果MyLoop正在等待MyLabel,我该如何继续WinWait

1 个答案:

答案 0 :(得分:0)

请参阅文档:ThreadsSetTimerWinWait

i := 0
settimer, afterTenMsg, 1000 ; Start our timer!
GoSub, WaitForNotepad 
ExitApp

WaitForNotepad:
    WinWait, Untitled - Notepad ; This Thread is interupted by the Timer.
    MsgBox % "Yeah NotePad Opened!" ; Close this will return to line 3
return

afterTenMsg:
    i++
    if (i == 10) {
        settimer, afterTenMsg, off
        run, notepad.exe
        settimer, openMsgBox, 1000 ; Interupt MsgBox thread after 1 sec
    }
return ; Returns to WinWait

openMsgBox:
    settimer, openMsgBox, off
    MsgBox % "We interupted a MsgBox!" ; close this will return to line 8
return

希望这有帮助。