這是示例程序,我發現,讓你切換回路的一些動作:autohotkey的異步執行如何工作?
; This toggles the action
toggle:=false
F12::
; If true is assigned to toggle, loop starts
; It also can assign false even when loop is running
If (toggle := !toggle)
SetTimer, loop, -1
return
loop:
; Endless loop? Actually not, the value of toggle can be changed by
; another "thread" even when this loop is running
while toggle
{
Click
Sleep, 700
}
return
現在我們可以看到,有一些超時實物-的呼叫啓動無限循環。無限循環顯然是同步的,沒有回調或同步塊或任何東西。
仍然,按F12似乎正常停止循環,即使它正在運行。
有人可以向我解釋在autohotkey中執行線程的方式嗎?它如何在沒有競爭條件的情況下處理多個代碼塊? SetTimer
調用在此扮演什麼角色?
不知道爲什麼你問不看的文檔:[詳細線程(https://autohotkey.com/docs/misc/Threads.htm) ,[SetTimer](https://autohotkey.com/docs/commands/SetTimer.htm)的否定超時。 – wOxxOm
@wOxxOm我用谷歌。我不會逐頁瀏覽文檔 - 我沒有時間去閱讀,即使答案在其他地方,提問也沒有錯。如果您不確定,也許可以閱讀幫助中心。 –
只需要不到1分鐘的時間打開文檔並搜索「線程」,另外1分鐘搜索「SetTimer」。發佈這個問題需要更多的時間。這就是我想知道的。 – wOxxOm