[英]AllocConsole(); with GetAsyncKeyState();
I've got some std::cout and std::cin commands between AllocConsole(); 我在AllocConsole()之间有一些std :: cout和std :: cin命令; and FreeConsole();, but when I press ctrl + caps lock the console just briefly flashes by and wont cout or wait for the cin. 和FreeConsole();,但是当我按ctrl +大写键锁定控制台时,只是短暂地闪烁而不会退出或等待cin。
Is this the wrong approach to set hotkeys for bringing up the console? 设置用于启动控制台的热键的方法是否错误?
if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_CAPITAL)){ // ctrl + caps
AllocConsole();
....
....
....
....
FreeConsole();
}
Thanks for your time. 谢谢你的时间。
Try GetAsyncKeyState(VK_CONTROL)&1 尝试GetAsyncKeyState(VK_CONTROL)&1
Either way, unless you put some Sleep()'s in there its just going open then close immediately. 无论哪种方式,除非您将一些Sleep()放在其中,否则它只会打开然后立即关闭。
This is definitely a job for RegisterHotKey 这绝对是RegisterHotKey的工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.