Keep a running C++ program console on top?

拈花ヽ惹草 提交于 2019-12-10 12:17:17

问题


Let's say I was using cin in my program to allow the user to input into the console. That is simple enough but what if they were typing into, let's say, a web browser and I wanted them to input that into the console at the same time? When I click away the C++ program console window and have something else on top, the input obviously does not go into the console. How can I make it so the console is always running on top so that even when I were to input something into a web browser, it would also go into the console?


回答1:


in order capture keyboard input when your application is not focused, you need to use windows hook, see:

http://msdn.microsoft.com/en-us/library/ms644959%28v=vs.85%29.aspx#wh_keyboardhook

Example code can be found here:

http://www.codeguru.com/cpp/w-p/system/keyboard/article.php/c5699/Hooking-the-Keyboard.htm




回答2:


I think you may want to take a look at hooking the keyboard to get the input?



来源:https://stackoverflow.com/questions/19212527/keep-a-running-c-program-console-on-top

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!