Repository navigation
Conversation
minh-tg
marked this pull request as ready for review
September 29, 2026 09:08
Author
|
CI is waiting for approval to run. Could a maintainer approve it when you have a moment? Thanks! |
`send_input_safe` called `SendInput` in a loop until it reported success. SendInput returns zero when the event is not inserted, because UIPI blocks it (for example while a window with a higher integrity level has focus) or because another thread blocked input. For as long as that lasts, the loop never ended. The daemon runs on a single-threaded runtime, so it stopped handling input and IPC, and the cleanup that releases held keys could not run either. The key repeat task spun the same way. Make a single attempt and return an error when it fails. The error ends the emulation session like any other emulation error. Releasing held keys is attempted on the way out, but goes through the same call and is refused too while the cause persists, so held keys can stay pressed. Stop the key repeat task when its injection is refused, and note the limitation in the README.
minh-tg
force-pushed
the
windows-bounded-sendinput
branch
from
October 9, 2026 10:37
10d9e92 to
b3a7c6b
Compare
Author
|
Reworked after a second look. The three immediate retries are gone because nothing changes |
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.
On Windows,
SendInputreturns 0 when it does not insert an event. That happens when UIPIblocks it, for example while a window started as administrator has focus, or when another
thread blocked input. Microsoft documents that neither the return value nor
GetLastErrorsays which one it was.
send_input_safecalledSendInputin a loop until it returned non-zero. For as long as therefusal lasted, the loop did not end. The daemon runs on a single-threaded runtime, so input
and IPC stopped, and so did the cleanup that releases held keys. The key repeat task had the
same loop.
Changes:
send_inputmakes one attempt and returns an error if it fails. Retrying in a loop wouldblock the runtime again.
is attempted on the way out, but it goes through the same call and is refused too while the
cause lasts, so held keys can stay pressed. Making
release_keyscontinue past a refused release is a separate change.With an elevated window focused, the log now shows
input emulation exited: ... SendInput refused the event, and emulation stays off until it isenabled again from the frontend. Before, the daemon froze.
I have not run this on Windows because I don't have a machine. CI compiles it. To check by hand:
run lan-mouse on Windows, focus a window started as administrator, send a key from the other
machine, and confirm the log line above and that emulation shows as disabled. Then enable it
again and confirm input works.
Related: #404 reports that Task Manager, which runs elevated, cannot be controlled and that input stops once it has focus. That may be this freeze. This change does not make elevated windows controllable. #373 proposes running as a Windows service, which would. #469 and #513 also edit
windows.rs, so whichever merges second needs a rebase.