Disabling left mouse click until all keys were sent

43 Views Asked by At

I have an AHK script, that is called from another application with a parameter:

text = %1%

WinWaitActive, foobar, , 5
if ErrorLevel {
  Exit
}

Sleep, 300
SendInput, %text%{Enter}

There can be issues if there is a click during the "sleep". So I would like to enable a hotkey like:

LButton::return

...during the sleep to block the mouse. The blocking should be disabled when the script finishes.

Is that possible?

2

There are 2 best solutions below

1
Relax On

You can disable one or more keys within a thread temporarily by using a boolean variable:

; begin of thread 
; ...

LButton_disabled := true 

; do something, in this case:    
Sleep, 300
SendInput, %text%{Enter}

LButton_disabled := false

; ...

return ; end of thread 


#If (LButton_disabled)

    LButton::return

#If 
1
Thomas W On

I found my problem can be solved with ExitApp:

text = %1%

WinWaitActive, foobar, , 5
if ErrorLevel {
  ExitApp
}

Sleep, 300
SendInput, %text%{Enter}

ExitApp
return


LButton::return