Alt key getting stuck

Ask gaming related questions (AHK v1.1 and older)
Ouataiveur
Posts: 6
Joined: 27 Mar 2022, 01:01

Re: Alt key getting stuck

Post by Ouataiveur » 11 Dec 2022, 14:37

Ok, better late than never but I have found a solution to the problem.

When you send anything without using {blind} AHK simulate the modifier corresponding to the key you want to send.
For instance if you send a "e" AHK is going to make sure it's going to be an "e" not a "shift+e" nor a alt+e or any other modifier combination.

And to achieve that AHK probably save the status of those modifier and restore those after the send action.
Unfortunately if a change of status of a modifier key physically happen right in the midst of this process it can result in the key getting "virtually" stuck at the windows level.

That is how I understand the problem. The thing that I can say is that I fixed this problem using send {blind}, controlsend,, {blind} in my case actually.

In some case you can't use send {blind} and in those case the only solution would probably be to look into AHK interception.
For going at the driver level of access is probably the only way to prevent that issue from happening in such cases...

User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Alt key getting stuck

Post by DavidP » 11 Dec 2022, 15:30

Thanks, will try that and report back!

User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Alt key getting stuck

Post by DavidP » 13 Dec 2022, 17:49

Well, after having changed every single Send to a Send {blind} in my script, I don't seem to perceive any improvement.

I still get stuck keys, mostly when mousing and typing away frantically at the same time. Even the Ctrl and Windows keys regularly get stuck for me.

In my desperation over the years I have developed the habit to hammer on all modifier keys one after the other every time a key gets stuck...

User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Alt key getting stuck

Post by DavidP » 25 Dec 2022, 06:42

It looks like now with the switch to send {blind} I get stuck CTRL keys all the time instead of stuck ALT keys.
This is even worse, unfortunately, as it triggers all sorts of possible and impossible actions, that can even lead to input data loss 😕

User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Alt key getting stuck

Post by DavidP » 11 Jan 2023, 07:22

Here's what ChatGPT :shock: said after examining my script:
One possible cause for the stuck modifier keys could be the use of the SendInput command, which is not as reliable as SendEvent for key press and release, but you have used Sendmode, Event in the initialization, which is supposed to change the default sending method to SendEvent mode. However, this doesn't guarantee that the script isn't still using SendInput somewhere else in the code. So, it would be a good idea to look for any instances of SendInput and replace them with SendEvent.

The script also uses the WinSet, Transparent command to set the transparency of the GUI window, it may be the source of the issue. So it would be a good idea to check if removing this line would solve the problem or not. The WinSet, Transparent command is used to set the transparency of a window, it uses the ahk_id parameter to target a specific window, in this case it's targeting the GUI window which created by the script by its handle (ahk_id %GUIWindowHandle%).

It's difficult for me to say for certain without testing the script, but it's possible that the transparency feature could be causing the stuck keys issue.

It's possible that this command could be causing some conflicts with the way the input is being handled by the script, leading to the stuck keys issue. The WinSet, Transparent command may also be using a lot of processing power, which could be causing the script to be less responsive to input.

Another possibility is that the window handle being used by the script might not be valid, or the window may be closed or hidden, which would cause the script to throw an error that could lead to unexpected behavior.

I would recommend trying to temporarily remove or commenting out the WinSet, Transparent command and see if it resolves the issue with the stuck keys, also try to check if the GUI window still displayed properly without transparency. It would also be helpful to add some error handling and checking to detect and handle any errors that may occur while running the script.
I'm going to try out this advice now....

User avatar
michaelbeijer
Posts: 83
Joined: 04 Oct 2014, 08:01
Location: Hastings, UK.
Contact:

Re: Alt key getting stuck

Post by michaelbeijer » 07 Feb 2023, 12:56

DavidP wrote:
13 Dec 2022, 17:49
Well, after having changed every single Send to a Send {blind} in my script, I don't seem to perceive any improvement.

I still get stuck keys, mostly when mousing and typing away frantically at the same time. Even the Ctrl and Windows keys regularly get stuck for me.

In my desperation over the years I have developed the habit to hammer on all modifier keys one after the other every time a key gets stuck...
Ha ha, I do that too! Drives me ******* crazy. I regularly get this annoying thing where (1) I suddenly can't type a question mark, and (2) navigating through text with ctrl+arrows and ctrl+shift+arrows is slow and stops and starts. Until I press Alt a few times, which (temprarily) fixes it.


[Mod edit: Removed expletive. Please refrain from their use in future posts.]
Michael Beijer
Dutch-English technical translator
Hastings, United Kingdom
Email: michael[at]beijer.uk
Website: Beijer.uk
Terminology: Beijerterm.com
AHK-learning project: Beijer.bot
Proz profile: proz.com/profile/652138
LinkedIn: linkedin.com/in/michael-beijer

User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Alt key getting stuck

Post by DavidP » 07 Mar 2023, 13:19

For a change, I now have the shift key stuck all the time. This is really dreadful

User avatar
DavidP
Posts: 225
Joined: 10 Aug 2014, 07:31

Re: Alt key getting stuck

Post by DavidP » 08 Apr 2024, 06:24

Oh if only something could be done about this...

Currently, I get the Windows key stuck like 50 times a day...

This issue totally disrupts my workflow every single day 😢😢😢

Post Reply

Return to “Gaming Help (v1)”