Repository navigation
Fix SendInput rejecting every keystroke: Input is 32 bytes, not 40 - #1
Open
verysaltyHH wants to merge 1 commit into
Open
verysaltyHH wants to merge 1 commit into
verysaltyHH wants to merge 1 commit into
Conversation
InputUnion declares only KEYBDINPUT, so Input marshals to 32 bytes. Win32 INPUT is 40 bytes on x64, because MOUSEINPUT is the largest member of its union. SendInput validates the size it is handed and rejects anything else with ERROR_INVALID_PARAMETER, so it has been returning 0 and delivering nothing. The keyboard fallback has never run. SendTeamsShortcut then returned true unconditionally, so InvokeOrShortcut reported success and the Stream Deck showed a delivered keystroke for a key that did nothing. It now returns what SendChord actually managed, and logs the Win32 error so the cause is visible rather than inferred. The self-test asserts the marshalled size, and CI runs the self-test. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
SendInputhas never delivered a keystroke.InputUniondeclares onlyKEYBDINPUT, soInputmarshals to 32 bytes. Win32INPUTis 40 bytes on x64, becauseMOUSEINPUTis the largest member of its union.SendInputvalidates the structure size it is handed and rejects anything else withERROR_INVALID_PARAMETER.The result is the log line
SendInput sent 0 of 6 keyboard events, on every machine, for every action, since the first release. The keyboard fallback the README documents has never run.Measured on Windows 11, .NET 8, win-x64:
Same call with
MOUSEINPUTdeclared in the union:The second half
SendTeamsShortcutreturnedtrueunconditionally, soInvokeOrShortcutreported success for a keystroke that was never sent. A key that did nothing still showed as successful on the Stream Deck, which is what made this hard to notice: the log said "Sent Teams' Ctrl+Shift+K hand shortcut" directly under the line saying nothing had been sent.It now returns what
SendChordactually achieved, so the key raises an alert, and logs the Win32 error so the cause is readable instead of inferred.5there would mean Windows refused to inject into a process at a higher integrity level, which is the failure the troubleshooting section already describes.Guard
The self-test now asserts the marshalled size, and CI runs the self-test, which it did not before. Removing the new union member makes it fail:
Scope and testing
Two files, +47/-5. No behaviour changes beyond the fallback path.
Verified against a live Teams desktop client on Windows 11:
--self-testpasses with the fix and fails without it, andSendInputreturns success where it previously returned 0. I have not tested the fallback end to end on every action, because with UI Automation working the fallback is only reached when UIA fails.Found while adding German control names to a fork; that work is separate and not part of this PR.
🤖 Generated with Claude Code