Reliably unpress stuck modifier keys

Ask gaming related questions
User avatar
Posts: 3
Joined: 07 Oct 2017, 17:54

Reliably unpress stuck modifier keys

29 Oct 2018, 13:43

I use keyboard shortcuts with Alt and Ctrl. I have a normal keyboard, not a gamer one, and the modifier keys often get stuck in the pressed state. Or I hold down the Alt myself with one hand, push the second key with the other, and don't release Alt in time before the function runs.

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

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

; I want this sub in several places
Send {RCtrl up}
Send {LCtrl up}
Sleep 40
Send {RAlt up}
Send {LAlt up}
Sleep 40
Posts: 2
Joined: 21 Jun 2016, 15:04

Re: Reliably unpress stuck modifier keys

25 Jan 2019, 15:51

I don't know, but I wish I did -- I have the same problem all the time ever since my Dell Latitude E7470 work computer got a Dell brand docking station.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 13 guests