Windows控制台中使用ReadConsoleInputW的Ctrl-S输入事件 [英] Ctrl-S input event in Windows console with ReadConsoleInputW

查看:50
本文介绍了Windows控制台中使用ReadConsoleInputW的Ctrl-S输入事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ReadConsoleInputW 来读取Windows 10控制台输入.我希望能够检测何时按下 Ctrl + S .使用我拥有的代码,我可以毫无问题地检测到 Ctrl + Q ,但是对于 Ctrl + S我什么都看不到.甚至可以检测到 Ctrl + S 吗?

I am using ReadConsoleInputW to read Windows 10 console input. I want to be able to detect when Ctrl+S is pressed. Using the code I have, I can detect Ctrl+Q without issue, but I'm not seeing anything for Ctrl+S. Is Ctrl+S even detectable?

以下是我按 Ctrl + S 几次,然后按 Ctrl 时读取的 INPUT_RECORD 的顺序kbd> + Q .

The below is the sequence of INPUT_RECORD I read when pressing Ctrl+S a few times, followed by Ctrl+Q.

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 }

如果有关系,可以使用 wio 在Rust中使用.

If it matters, this is in Rust using wio.

推荐答案

使用 ENABLE_WINDOW_INPUT调用 SetConsoleMode |ENABLE_MOUSE_INPUT |ENABLE_EXTENDED_FLAGS 作为第二个参数(因此禁用了 ENABLE_PROCESSED_INPUT )成功了.

Calling SetConsoleMode with ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT | ENABLE_EXTENDED_FLAGS as the second argument (thus disabling ENABLE_PROCESSED_INPUT) did the trick.

这篇关于Windows控制台中使用ReadConsoleInputW的Ctrl-S输入事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆