fix(windows): suppress consumed hotkey trigger events#261
Merged
H-Chris233 merged 1 commit intoMay 5, 2026
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
H-Chris233
approved these changes
May 5, 2026
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.
User description
问题描述
修复 #195:Windows 浏览器输入框在语音输入完成后丢失光标,导致识别文本无法插入。
已在 Windows 11 + Chrome 中复现,影响 Gemini、Google 搜索、百度搜索等网页输入框。ASR 和文本生成本身成功,但插入阶段找不到有效的网页光标位置。
根本原因:
Windows 低级键盘 hook 已经识别并处理 OpenLess 的触发键,但处理后仍继续调用
CallNextHookEx,导致配置的触发键事件继续传递给前台应用。当触发键是右 Alt / AltGr 等修饰键时,Chrome 网页输入框会收到这个按键事件,并可能清空 DOM caret / selection。后续 TSF、Unicode SendInput 或剪贴板粘贴 fallback 虽然执行了,但页面输入框已经没有可插入位置。
修复方案
1. 消费已处理的 Windows 触发键事件
文件:
openless-all/app/src-tauri/src/hotkey.rs在 Windows
WH_KEYBOARD_LL回调中,让dispatch_keyboard_event返回当前事件是否已经被 OpenLess 作为触发键处理。如果事件是配置的触发键,则在发送
Pressed/Released事件后返回LRESULT(1),阻止该触发键继续传递到前台应用。2. 保持非触发键行为不变
以下路径继续透传,不改变现有行为:
测试验证
自动检查
cargo check --manifest-path src-tauri/Cargo.toml结果:通过。当前仓库已有的 Rust warnings 仍存在,本 PR 未新增相关 warning。
手动验证
环境:Windows 11 + Chrome。
已验证以下网页输入框可以正常保留光标并插入语音识别结果:
风险评估
低风险:
行为影响:
如果用户将右 Alt、右 Ctrl 等单键配置为 OpenLess 触发键,该触发键在 OpenLess 运行并被 hook 捕获时不会再传递给前台应用。这符合全局触发键的预期行为,并避免浏览器输入框丢失光标。
PR Type
Bug fix
Description
Consume Windows trigger hotkeys
Preserve non-trigger key behavior
Prevent input focus loss
Diagram Walkthrough
File Walkthrough
hotkey.rs
Stop consumed hotkeys from reaching appsopenless-all/app/src-tauri/src/hotkey.rs
dispatch_keyboard_eventnow returns a boolean indicating whether thekey was consumed.
LRESULT(1)when the configuredtrigger key is handled.
Esc, andShifthandling continue to pass throughunchanged.