【发布时间】:2017-02-03 08:38:26
【问题描述】:
我正在使用 ReadConsoleInputW 读取 Windows 10 控制台输入。我希望能够检测到何时按下 Ctrl+S。使用我拥有的代码,我可以检测到 Ctrl+Q 没有问题,但我没有看到任何 Ctrl+S 。 Ctrl+S 甚至可以检测到吗?
下面是我按Ctrl+S几次后看到的INPUT_RECORD的序列,接着是Ctrl+问。
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 17, scan_code: 29, wide_char: 0, control_key_state: 40 }
Key { key_down: true, repeat_count: 1, key_code: 81, scan_code: 16, wide_char: 17, control_key_state: 40 }
如果重要的话,这是在 Rust 中使用 wio。
【问题讨论】:
-
您使用的是哪个终端模拟器?你在用
cmd.exe吗?电源外壳?像bash这样的东西?终端模拟器程序会拦截该组合键吗? -
您可以尝试使用
SetConsoleMode禁用ENABLE_PROCESSED_INPUT吗? -
我正在使用
cmd.exe。今晚我会尝试禁用ENABLE_PROCESSED_INPUT。谢谢。 -
看来
ENABLE_LINE_INPUT是罪魁祸首!请看我的回答。
标签: winapi rust console-application