[Known Limitation] SendInput prevents detection of another hotkey when invoked from a mouse hotkey

Report problems with documented functionality
dossist
Posts: 2
Joined: 25 Jul 2018, 02:28

[Known Limitation] SendInput prevents detection of another hotkey when invoked from a mouse hotkey

25 Jul 2018, 03:11

Edit2: This behavior is a known limitation of SendInput. In this case, SendEvent should be used instead.
Edit1: The reason why pressing another key after holding down LShift gets the correct result, was probably because auto-repeat of LShift stops once another key is pressed.

Possible bug with SendInput.
The bug occurs when doing following things:
  • Set a mouse hotkey
  • Use SendInput (not SendEvent) inside the mouse hotkey
  • Set another hotkey for a keyboard key
The keyboard hotkey is sometimes missed while spamming the mouse hotkey.
Testing environment: AHK 1.1.29.01, Windows 10 1803 (build 17134.167), USB keyboard/USB mouse.

Here is an example:

Code: Select all

#HotkeyInterval 100 ; to prevent popup warning
#KeyHistory 500 ; for better log analysis
#NoEnv

SendMode Input ; Problem occurs with SendInput

; Set a mouse hotkey. Scroll down your mouse wheel to send "a"
*WheelDown::
    Send, {Blind}{a}
    return

; Ignore LShift (another hotkey)
*LShift::return
*LShift up::return

; A rescue key to recover LShift from being permanently down
*PrintScreen::
    Send, {Blind}{LShift up}
    return
In notepad, hold down LShift and spam WheelDown with your mouse. Initially you will see a lot of lowercase "a" because LShift is ignored by AHK, but after a while uppercase "A" will appear. This indicates that while you are spamming WheelDown, AHK somehow missed to catch one of LShift event, thus the LShift managed to slip through AHK's blocking.
If you don't reproduce the behavior, try setting your keyboard repetition rate to the fastest side in Windows.

Strangely, if you hold down LShift, then press any keyboard key (for example, press "b" and release, just once will do) and spam WheelDown, AHK works just fine without any problem.
Also, SendEvent seems to work without the bug too, but it sometimes misses LShift hotkey only when LShift and WheelDown are pressed (sent) at exactly the same time.
Last edited by dossist on 25 Jul 2018, 04:05, edited 1 time in total.
Helgef
Posts: 3296
Joined: 17 Jul 2016, 01:02
Contact:

Re: SendInput prevents detection of another hotkey when invoked from a mouse hotkey

25 Jul 2018, 03:29

When sending with sendinput the keyboard hook is disabled, so ahk will not be able to block the shift down event. It's a limitation of the implementation or windows if you like. You should use sendevent.

Cheers.
dossist
Posts: 2
Joined: 25 Jul 2018, 02:28

Re: SendInput prevents detection of another hotkey when invoked from a mouse hotkey

25 Jul 2018, 04:02

Helgef, thanks very much for the tips!
I'm sorry that it was a known limitation.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests