我使用ReadConsoleInputW
來讀取Windows 10控制檯輸入。我希望能夠檢測何時按下Ctrl + S被按下。使用我的代碼,我可以檢測按Ctrl +Q沒有問題,但我不按Ctrl +小號看到什麼。是Ctrl + S甚至可檢測?Windows控制檯中的Ctrl-S輸入事件(ReadConsoleInputW)
的下面是INPUT_RECORD
序列按壓Ctrl鍵 + 小號幾次,當我讀,隨後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 }
如果重要,這是在Rust使用wio
。
您正在使用哪種終端模擬器?你使用'cmd.exe'嗎?電源外殼?像bash一樣?終端模擬器程序是否可以攔截該組合鍵? – Shepmaster
您可以嘗試使用['SetConsoleMode'](https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v = vs.85).aspx)禁用'ENABLE_PROCESSED_INPUT'? – wimh
我正在使用'cmd.exe'。我會嘗試在今晚禁用'ENABLE_PROCESSED_INPUT'。謝謝。 – oconnor0