保持运行的C ++程序控制台顶部? [英] Keep a running C++ program console on top?
问题描述
假设我在我的程序中使用 cin
,以允许用户输入到控制台。这很简单,但如果他们正在输入,比方说,一个Web浏览器,我想让他们同时输入到控制台?当我点击远离C ++程序控制台窗口,并在顶部有其他东西,输入显然不会进入控制台。如何使控制台总是运行在最上面,这样即使我在浏览器中输入内容,它也会进入控制台?
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?
推荐答案
为了捕获键盘输入,当您的应用程序不专注时,您需要使用Windows钩子,请参阅:
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/wp/system/keyboard/article.php/c5699/Hooking-the-Keyboard.htm
这篇关于保持运行的C ++程序控制台顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!