Modifiers getting stuck

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Leli196
Posts: 216
Joined: 29 Aug 2015, 05:47
Location: Germany

Modifiers getting stuck

11 Apr 2021, 12:35

Hi there,

I have a problem with modifiers getting stuck until I press them again physically.
I noticed that this from time to time, but now have it narrowed down to (not exclusively) one hotkey and the problem persists if only this code is in the script:

Code: Select all

^!+t::
SendInput, !{Enter}
KeyWait, t
if (A_TimeSinceThisHotkey >= 300)
	SendInput, {Esc}
Return
KeyHistory:

Code: Select all

Window: C:\Users\...
Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) = LShift LCtrl 
Modifiers (Hook's Logical) = LShift LCtrl 
Modifiers (Hook's Physical) = 
Prefix key is down: no

NOTE: To disable the key history shown below, add the line "#KeyHistory 0" anywhere in the script.  The same method can be used to change the size of the history buffer.  For example: #KeyHistory 100  (Default is 40, Max is 500)

The oldest are listed first.  VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event.  Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script, a=Artificial, #=Disabled via #IfWinActive/Exist, U=Unicode character (SendInput).

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------          	
A2  01D	 	d	1.64	LControl       	Downloads
A0  02A	 	d	0.00	LShift         	
A4  038	 	d	0.00	LAlt           	
54  014	h	d	0.00	t              	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
0D  01C	i	d	0.01	Enter          	
0D  01C	i	u	0.00	Enter          	
A4  038	i	u	0.00	LAlt           	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
54  014	h	d	0.23	t              	Eigenschaften von WinMerge
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.05	t              	
54  014	h	d	0.03	t              	
54  014	s	u	0.00	t              	
A4  038	i	u	0.01	LAlt           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
1B  001	i	d	0.02	Escape         	
1B  001	i	u	0.00	Escape         	
A4  038	i	d	0.00	LAlt           	
A2  01D	 	u	0.02	LControl       	
A0  02A	 	u	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A4  038	 	u	0.00	LAlt           	
Press [F5] to refresh.
Shift and Ctrl are stuck here until I press them again physically. It also happens with Alt and in every combination of the modifiers.


KeyHistory of my original script:

Code: Select all

Window: Downloads
Keybd hook: yes
Mouse hook: yes
Enabled Timers: 1 of 1 (MonitorDimTimer)
Interrupted threads: 0
Paused threads: 0 of 1 (0 layers)
Modifiers (GetKeyState() now) = LShift 
Modifiers (Hook's Logical) = LShift 
Modifiers (Hook's Physical) = 
Prefix key is down: no

NOTE: To disable the key history shown below, add the line "#KeyHistory 0" anywhere in the script.  The same method can be used to change the size of the history buffer.  For example: #KeyHistory 100  (Default is 40, Max is 500)

The oldest are listed first.  VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event.  Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script, a=Artificial, #=Disabled via #IfWinActive/Exist, U=Unicode character (SendInput).

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------   	
A2  01D	 	d	0.73	LControl       	Downloads
A0  02A	 	d	0.00	LShift         	
A4  038	 	d	0.00	LAlt           	
54  014	 	d	0.00	t              	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
0D  01C	i	d	0.02	Enter          	
0D  01C	i	u	0.00	Enter          	
A4  038	i	u	0.00	LAlt           	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
54  014	 	d	0.25	t              	Eigenschaften von WinMerge
54  014	 	d	0.05	t              	
54  014	 	d	0.03	t              	
54  014	 	d	0.05	t              	
54  014	 	u	0.05	t              	
A4  038	i	u	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
1B  001	i	d	0.00	Escape         	
1B  001	i	u	0.02	Escape         	
A2  01D	 	u	0.00	LControl       	
A0  02A	 	u	0.00	LShift         	
FF  000	i	d	0.00	^              	; MenuMaskKey
A4  038	 	u	0.00	LAlt           	
A4  038	i	d	0.00	LAlt           	
FF  000	i	u	0.01	^              	
A0  02A	i	d	0.00	LShift         	
Press [F5] to refresh.
Shift is stuck here.


So what can I do here? The keyboard-hook is installed, I use SendInput, #MenuMaskKey has no effect here and I do not know what else I could try.

System:
Win10 Home Version 10.0.19041 Build 19041
AHK Unicode 64-Bit 1.1.33.06
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Modifiers getting stuck

11 Apr 2021, 13:44

I would probably use a different hotkey.

Code: Select all

F3::
SendInput !{Enter}
KeyWait, %A_ThisHotkey%
SendInput % A_TimeSinceThisHotkey > 300 ? "{Esc}" : ""
Return
Leli196
Posts: 216
Joined: 29 Aug 2015, 05:47
Location: Germany

Re: Modifiers getting stuck

11 Apr 2021, 16:20

Well, that is a workaround, but no solution. I have many hotkeys with modifiers and not enough single keys to map them to, also it is inconvenient.

I wonder why AHK makes the modifiers stuck in the first place. Everything seems correct in the KeyHistory at first, the modifiers get released (logically) to let SendInput send the keystrokes !Enter correctly, the modifiers then get pressed down again (logically). Before the second SendInput it is the same, but after it – where the modifiers are also released physically – things are mixed up. The keyup events of the physical release happen before the keydown events succeeding SendInput.

This

Code: Select all

A4  038	i	u	0.01	LAlt           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
1B  001	i	d	0.02	Escape         	
1B  001	i	u	0.00	Escape         	
A4  038	i	d	0.00	LAlt           	
A2  01D	 	u	0.02	LControl       	
A0  02A	 	u	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	; logical keydowns after keyup –> keys stuck
A0  02A	i	d	0.00	LShift         	
A4  038	 	u	0.00	LAlt    
Should be this

Code: Select all

A4  038	i	u	0.01	LAlt           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
1B  001	i	d	0.02	Escape         	
1B  001	i	u	0.00	Escape         	
A4  038	i	d	0.00	LAlt           	; keydown first
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A4  038	 	u	0.00	LAlt    		; keyup (physically) second
A2  01D	 	u	0.02	LControl       	
A0  02A	 	u	0.00	LShift         	
Does that make sense? Any more ideas on this?
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Modifiers getting stuck

11 Apr 2021, 16:25

It's tricky to press Alt while you then also want AHK to press Alt. The "stuck key" is a known phenomenon-- reportedly due to conflicting software, according to some. You can try sending Alt up and the like; it sometimes works. In some cases, there are also ways to use {Blind} to make the sequences work properly. Another approach can be to separate the second sequence into a "key up" routine instead of using the KeyWait, but that might not help you here.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Modifiers getting stuck

11 Apr 2021, 22:54

Unless SendInput has fallen back to SendEvent due to the presence of another script with a hook, keys cannot be logged into KeyHistory while a SendInput is in progress, because the keyboard hook is temporarily uninstalled. SendInput builds an array of events, including both the events used to release the unwanted modifiers and the events used to restore them afterward. This array is passed to the native SendInput function, which then sends the keystrokes. SendInput is supposed to be uninterruptible; if the user presses or releases any keys during the send, the system is supposed to buffer the corresponding events so that they are handled after those which were passed to SendInput (such as the events intended to restore the modifiers).

However, in your case the events are clearly interspersed. I assume this means you have multiple scripts running, and SendInput is falling back to SendEvent mode. In that case, after sending whatever you specified, it checks the physical modifier state according to the keyboard hook, then sends events to restore any modifiers which are physically down but not logically down. I think this is (in theory) prone to a race condition where the user might physically release the keys after Send checks the current state but before the events which are sent to restore them are processed.

There aren't any good solutions, but I think the best solution is to avoid using the keyboard hook in more than one active script (or to merge any scripts that require the keyboard hook).
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Modifiers getting stuck

12 Apr 2021, 05:25

Thank you, @lexikos!
Leli196
Posts: 216
Joined: 29 Aug 2015, 05:47
Location: Germany

Re: Modifiers getting stuck

14 Apr 2021, 10:02

Thanks for the good explanation @lexikos
I would be very grateful if you read this post, although it not that short.


It took me a while to figure stuff out. I forgot to mention that the stuck keys do not happen always, but occasionally. It happens often when I try to provoke it by releasing the modifiers in the exact moment SendInput is active, then stuff gets mixed up (in about 1 out of 5 tries). That matches your explanation.

The KeyHistory of the code in my first post showed that the keyboard hook is active, despite it being the only script running and containing only the stated code. When I run it now, the hook is not active (as expected) and the stuck modifiers do not happen; but my main script uses the hook due to numerous hotkeys.

The following code has the hook active and then the stuck modifiers happen again, although there are no other scripts running. According to your explanation this should not happen as the script uses SendInput and there is no other script using the keyboard hook.

Code: Select all

#InstallKeybdHook

^!+t::
SendInput, !{Enter}
KeyWait, t
if (A_TimeSinceThisHotkey >= 300)
	SendInput, {Esc}
Return
So why is there a fallback to SendEvent here?

The documentation states:
If a script other than the one executing SendInput has a low-level keyboard hook installed, SendInput automatically reverts to SendEvent.
As there is no other script, could there be another program using a keyboard hook?
Also, is there a method to immediately see that there is a fallback of SendInput to SendEvent?

This post I discovered answers the questions already:
lexikos wrote:
04 Nov 2019, 03:02
If SendInput detects another AutoHotkey script with a hook, it automatically falls back to SendEvent mode. However, there are actually two hooks: a mouse hook and a keyboard hook. SendInput only checks for the type of hook that would detect the events it is about to send. Your script is sending both types (due to automatic releasing of Alt), therefore the presence of another script with either type of hook would cause SendInput to fall back to SendEvent mode. In that case, SendInput() isn't used at all, so the system does not buffer the user's keystrokes.

AutoHotkey cannot detect hooks; it can only detect the presence of a "mutex" that AutoHotkey scripts register when they install a hook. If a non-AutoHotkey program installs a keyboard or mouse hook, it will not be detected, because it does not create this mutex. If the only script with a hook is the one calling SendInput, it will not fall back to SendEvent mode; it will call SendInput(). Since there will be a hook present when SendInput() is called, the system will not buffer the user's keystrokes.

KeyHistory only shows events that the script can detect, or that the script itself generates. Unless it is falling back to SendEvent or SendPlay, SendInput deactivates the script's own keyboard and mouse hooks immediately before calling SendInput() and reactivates them after it returns. Events that are not generated by the script cannot be detected while SendInput() is in progress, because the hooks are not active. (Normally that shouldn't matter, because the events are buffered and not processed until after SendInput() returns anyway. But if a non-AutoHotkey hook is present, the user's keystrokes are not buffered and therefore may be processed while AutoHotkey's hook is inactive. They will not appear in KeyHistory in that case.)

In your case, KeyHistory is showing physical keyboard events interspersed with the events generated by SendInput. Therefore, SendInput must be falling back to SendEvent or SendPlay. It must be failing to acquire the "AHK Keybd" or "AHK Mouse" mutex (meaning another AutoHotkey script has a hook active).

It does not matter whether the script which is calling SendInput has hooks, because those hooks can be automatically deactivated and reactivated by SendInput.

SendEvent does not perform buffering; it calls keybd_event() once for each event, and optionally sleeps in between (according to SetKeyDelay).

SendInput does not perform buffering of the user's keystrokes; it cannot, because it is not processing the user's keystrokes. Rather, if SendInput calls SendInput(), the system may or may not buffer the user's keystrokes while the events are being sent. SendInput is designed under the assumption that the system will buffer keystrokes only if there are no hooks installed.

When I run the following code and press other keys during the SendInput, the keys are not buffered, but interspersed (in the output as well as KeyHistory):

Code: Select all

#InstallKeybdHook
#KeyHistory 500

F1::
SendInput, ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sleep, 1000
KeyHistory
Return
Output: (I removed a bit from the beginning for clarity.)

Code: Select all

---a------------------------------------------------------e---------------------------i---------------------------------h----------------------------------------------------------------------------------------------------------------------------------------a------------------------------------h----------e------i--------------------------------------------------------------------------------------------------------------------------------
KeyHistory:

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
48  023	 	u	0.00	h              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.01	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.02	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.02	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.01	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
41  01E	 	d	0.00	a              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.02	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.01	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
48  023	 	d	0.00	h              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
45  012	 	d	0.00	e              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.02	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
49  017	 	d	0.00	i              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.02	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.01	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
49  017	 	u	0.00	i              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.02	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
45  012	 	u	0.00	e              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.02	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
41  01E	 	u	0.00	a              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
48  023	 	u	0.00	h              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.01	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.02	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.01	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.02	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
Press [F5] to refresh.
It looks exactly the same like it does when SendEvent is used with the corresponding SetKeyDelay, also the input speed is the same:
SendEvent results

Looks correct for SendEvent to me, but not for SendInput.


As I have tested whether some program could interfere with AutoHotkey I found out that SciTE4AutoHotkey v3.0.06.01 indeed does.
When it is running (minimized), AHK behaves like the above examples. When it is not running, the keystrokes of SendInput are indeed buffered (at least mostly) when I test it with the same code (buffered keystrokes at the end):

Code: Select all

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------a----------------------------------------------------------------------eihaeaa

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.01	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
BD  035	i	d	0.00	-              	
BD  035	i	u	0.00	-              	
45  012	 	d	0.28	e              	
49  017	 	d	0.06	i              	
48  023	 	d	0.00	h              	
41  01E	 	u	0.02	a              	
45  012	 	u	0.06	e              	
49  017	 	u	0.02	i              	
41  01E	 	d	0.06	a              	
48  023	 	u	0.02	h              	
45  012	 	d	0.08	e              	
45  012	 	u	0.11	e              	
41  01E	 	u	0.08	a              	
41  01E	 	d	0.23	a              	
41  01E	 	u	0.13	a              	
41  01E	 	d	0.14	a              	
41  01E	 	u	0.08	a              	
This looks more correct for SendInput to me.


Regarding the original problem, I thought it was fixed now. Unfortunately, when it comes to stuck modifier keys having SciTE4AutoHotkey not running still resulted in stuck keys.
Instead of this in the KeyHistory

Code: Select all

Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) = LShift LCtrl 
Modifiers (Hook's Logical) = LShift LCtrl 
Modifiers (Hook's Physical) = 
Prefix key is down: no
or this

Code: Select all

Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) = LShift LCtrl 
Modifiers (Hook's Logical) = 
Modifiers (Hook's Physical) = 
Prefix key is down: no
I have this now:

Code: Select all

Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 1 (0 layers)
Modifiers (GetKeyState() now) = LShift LCtrl
Modifiers (Hook's Logical) = LShift LCtrl
Modifiers (Hook's Physical) = LShift LCtrl
Prefix key is down: no

...

A4  038	i	u	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
1B  001	i	d	0.00	Escape         	
1B  001	i	u	0.00	Escape         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift     		; no keyup events at all, despite modifiers not held physically anymore
which always results in Shift and Ctrl being stuck, and in the last example the modifiers are not held physically. The script now just thinks I am still holding the modifier keys and they are stuck until I physically press them again.
lexikos wrote:
11 Apr 2021, 22:54
There aren't any good solutions, but I think the best solution is to avoid using the keyboard hook in more than one active script (or to merge any scripts that require the keyboard hook).
I am clueless now. When I understand your explanation correctly, having only one single script running should not result in stuck modifier keys, but it still happens.
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Modifiers getting stuck

14 Apr 2021, 10:12

As you have discovered, other program, not just AHK, can use a keyboard hook. It could be a clipboard manager, media player, document indexer, or any of a large number of other programs.
Leli196
Posts: 216
Joined: 29 Aug 2015, 05:47
Location: Germany

Re: Modifiers getting stuck

14 Apr 2021, 10:20

To my understanding in that case the keystrokes should not appear in KeyHistory, though. And in my case they do appear there. Or can they still be buffered and would appear in KeyHistory then? But if they are buffered and processed afterwards, why the completely (even allegedly physically) stuck keys?
lexikos wrote:
04 Nov 2019, 03:02
But if a non-AutoHotkey hook is present, the user's keystrokes are not buffered and therefore may be processed while AutoHotkey's hook is inactive. They will not appear in KeyHistory in that case.)
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Modifiers getting stuck

14 Apr 2021, 10:30

@lexikos will know the answer. My crude understanding is that other software can still conflict and yet is difficult to identify. As noted, too, the keystrokes might not be buffered and might not appear in the key history. There could even be multiple such programs running at the same time.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Modifiers getting stuck

14 Apr 2021, 22:00

I read up to where you mentioned SciTE4AutoHotkey, and skipped the rest.

Half of the toolbar is implemented by an AutoHotkey script. I don't recall whether it uses hook hotkeys. By default S4A also runs a script named TillaGoto, which uses the mouse hook (and maybe keyboard hook, I forget). If you run the debugger, that is also an AutoHotkey script, and it uses hook hotkeys.
Leli196
Posts: 216
Joined: 29 Aug 2015, 05:47
Location: Germany

Re: Modifiers getting stuck

19 Apr 2021, 07:04

@lexikos Yeah, I realized that SciTE4AutoHotkey messes with AutoHotkey. However, the most important part came after I mentioned SciTE4AutoHotkey.

Without SciTE4AutoHotkey running (and also TillaGoto) I have the problem that the modifiers are detected as physically down, although they are not held physically anymore, which makes them stuck as well (tested on multiple computers with same result):

Code: Select all

Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 1 (0 layers)
Modifiers (GetKeyState() now) = LShift LCtrl
Modifiers (Hook's Logical) = LShift LCtrl
Modifiers (Hook's Physical) = LShift LCtrl
Prefix key is down: no

...

A4  038	i	u	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
1B  001	i	d	0.00	Escape         	
1B  001	i	u	0.00	Escape         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift     		; no keyup events at all, despite modifiers not held physically anymore
When there is a discrepancy between the physical and logical state of a key retreived with GetKeyState() I could at least release the stuck modifiers with keyup events, but when even the hook falsely deems the modifiers to be physically down there is zero chance to recognize stuck modifiers. Also I cannot implement KeyWait to have the modifiers released before there is a possibility for them to get stuck.


Can you confirm that this is not the standard behaviour when there is only one script running? If yes, does that mean there is still something interfering with AutoHotkey?

Is there anything that can be done to at least prevent the physical state to be falsely positive? It happens with a varying frequency, sometimes 3 out of 10 times, sometimes less often (when I provoke it).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, wilkster and 315 guests