我想隐藏用户C / C ++的控制台和输入 [英] I want to hide console and input from user C/C++
本文介绍了我想隐藏用户C / C ++的控制台和输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我想编写一个 c / c ++ 代码,隐藏控制台屏幕并在后台工作,我想我成功地做到了这一点。现在我正在尝试编写一个在后台运行的代码,并从用户那里获取输入。
我尝试过:
我使用此代码隐藏控制台
Hello every one!
I want to write a c/c++ code that will hide console screen and work in background and i'm successful to do this. Now i'm trying to write a code that work in background and also take input from user.
What I have tried:
I use this code to hide console
#include "stdafx.h"
#include"iostream"
#include "windows.h"
using namespace std;
void main() {
//These four lines hides the console
HWND window;
AllocConsole();
window = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(window, 0);
int a;
cin >> a; //Here i have want input to do some action
}
任何人都可以帮我解决这个问题。我正在使用visual studio 2013
Can any one help me to solve this problem. I'm using visual studio 2013
推荐答案
除非您的应用程序窗口具有焦点,否则您无法从用户那里获取输入:以及隐藏在后台应用程序没有显示窗口的窗口不能有焦点,所以你无法获得用户输入!
你为什么要这样做?如果你成功,你会混淆用户......
You can't take input from the user unless your app window has the focus: and a "hidden in the background" app that doesn't show a window can't have the focus, so you can't get the user input!
Why are you trying to do this? You will confuse users no end if you succeed...
这篇关于我想隐藏用户C / C ++的控制台和输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文