2016-09-15 24 views
1

我有SetTimers指向多個標籤,但他們在其中一個標籤中有WinWait時停止工作。如何在不阻礙其他人的情況下在多個標籤上使用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的運行?

+0

檢查窗口是否存在於內含「睡眠20」的循環中。 – wOxxOm

回答

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 

希望這有助於。

+0

我想使用'WinWait'而不是僞循環來優化腳本的資源消耗。 – user400424

+0

我使用WinWait更新了我的示例,以顯示它可以用SetTimer中斷。添加的註釋用於引用代碼將返回到線程完成時的位置。希望你能從中得到更好的理解。我真的建議你閱讀我發佈的所有三個鏈接,因爲我沒有顯示每個案例或示例。例如,您可以優先考慮計時器,甚至將子例程/函數設置爲不可中斷,這些信息包含在文檔中。 – errorseven

相關問題