If Alt is down and I send {Enter} or {Esc} in my script to browse dialogs (with Send), it is interpreted as Alt-Enter or Alt-Esc or Ctrl-Esc which is very, very bad, as it causes the game to minimize and/or the start menu to open. It hasn't been a problem when sending a complete string with SendInput, but I need to hold down a key sometimes with Send {Esc down}, Sleep, Send {Esc up}. I tried using "KeyWait Alt" at the start of the script, but it didn't always protect against Alt-Esc.
What are ways to reliably, rigorously unpress any possible pressed keys programmatically with minimum time spent in the execution with Sleep? And also ensure that they are in up state if still physically held down (I think "BlockInput On" handles it but I am not sure).
Also I want to forcibly unpress keys even if there is a way to use KeyWait, as they remain pressed outside of the game too.
Code: Select all
$>!>+NumpadMult::
BlockInput On
Gosub ReleaseModifiers
SendInput blah{enter}
; send several commands with Send
Sleep 500
; at this point Alt is usually released but might not be
Send {Down}
Sleep 80
Send {Enter}
Sleep 80
Send {Esc down}
Sleep 40
Send {Esc up}
BlockInput Off
return
; I want this sub in several places
ReleaseModifiers:
Send {RCtrl up}
Send {LCtrl up}
Sleep 40
Send {RAlt up}
Send {LAlt up}
Sleep 40
return