简体   繁体   English

保持运行的C ++程序控制台在最前面?

[英]Keep a running C++ program console on top?

Let's say I was using cin in my program to allow the user to input into the console. 假设我在程序中使用cin允许用户输入到控制台。 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? 这很简单,但是如果他们要输入一个Web浏览器,那又该如何将它们同时输入到控制台呢? When I click away the C++ program console window and have something else on top, the input obviously does not go into the console. 当我单击C ++程序控制台窗口并在顶部放置其他内容时,输入显然不会进入控制台。 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? 如何使控制台始终运行在顶部,以便即使我在Web浏览器中输入内容,控制台也可以进入控制台?

我想您可能想看看挂钩键盘来获取输入?

in order capture keyboard input when your application is not focused, you need to use windows hook, see: 为了在应用程序不集中时捕获键盘输入,您需要使用Windows钩子,请参阅:

http://msdn.microsoft.com/en-us/library/ms644959%28v=vs.85%29.aspx#wh_keyboardhook http://msdn.microsoft.com/zh-cn/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 http://www.codeguru.com/cpp/wp/system/keyboard/article.php/c5699/Hooking-the-Keyboard.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM