Fix garbled typing on Windows: use type() instead of per-char press/release#25
Open
obbax wants to merge 1 commit intogurjar1:mainfrom
Open
Fix garbled typing on Windows: use type() instead of per-char press/release#25obbax wants to merge 1 commit intogurjar1:mainfrom
obbax wants to merge 1 commit intogurjar1:mainfrom
Conversation
…elease The original code used keyboard_controller.press(char) + release(char) for each character with a delay, which causes garbled/duplicated output on Windows due to pynput's key event handling. Replaced with keyboard_controller.type(text_to_type) which uses Windows native text input API for clean, reliable typing. Tested on Samsung Galaxy Book (Intel Core Ultra 7, Windows 11 Pro). Swedish dictation works perfectly with this fix. Fixes gurjar1#16, gurjar1#15
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.
Problem
On Windows, the typing mechanism produces garbled/duplicated text because it uses
keyboard_controller.press(char)+keyboard_controller.release(char)for each character individually. This is a known issue (#16, #15).Root Cause
pynput's per-character press/release sends individual keydown/keyup events which get mangled by Windows keyboard buffering, especially on CPU (int8) with non-English languages.
Fix
Replaced the per-character loop with
keyboard_controller.type(text_to_type)which uses Windows native text input API to type the entire string cleanly.Testing