Thanks just me.
I'd prefer to use the workaround of increasing the message check interval, as it seems less convoluted than posting a second message to the script. But it doesn't seem to work: setting Critical 1000 doesn't block the second mouse click from arriving if clicked within a second.
Also what's the deal with the 2 thread limit - only 2 msgboxes can be waiting simultaneously. Is this some kind of hard coded thread limit in ahk?
edit: the Critical problem appears to be related to msgboxes (and also Sleep) since it doesn't occur if doing some other code like this
Code: Select all
#NoEnv
Gui, Show, Center w400 h400, OnMessage()
OnMessage(0x0201, "MouseMessage") ; WM_LBUTTONDOWN
OnMessage(0x0204, "MouseMessage") ; WM_RBUTTONDOWN
Return
MouseMessage(W, L, M, H) {
Critical 3000
If (M = 0x0201){
MsgBox Starting WM_LBUTTONDOWN
;Sleep 10000 ;doesn't work - WM_RBUTTONDOWN will interrupt immediately
;MsgBox WM_LBUTTONDOWN ;doesn't work - WM_RBUTTONDOWN will interrupt immediately
loop 100000000000 ;works - WM_RBUTTONDOWN will buffer for up to 3000ms (but could be
var++ ;much less if ahk's message check interval happened to finish recently!)
MsgBox Finished WM_LBUTTONDOWN
}
If (M = 0x204)
MsgBox WM_RBUTTONDOWN
Return 0
}
GuiClose:
ExitApp
edit: ah
So we cannot actually use msgboxes to test this. But it just so happens the result is the same when replacing msgbox with
loop var++, and even when making the function Critical (without second parameter).
But there is still the unsolved mystery of why
Sleep 10000 allows immediate interrupts, but
loop var++ doesn't. And the mystery of the 2 msgbox maximum.