Multiple inputs in c++ console (windows) - c++

I need to create a console application (c++ windows) as a subprocess that will accept input both by the user and by the parent parent process. I would like to know if that is feasible and how.
Thanks.
Panagiotis

This should be fairly straightforward:
stdin is the redirected input from the parent process or input pipe
open a file named "CONIN$" to get keyboard input from the console window

Related

Multiple consoles for a single application C++

Is it possible to create two console windows (one being the main) and the secondary being a pop-up like a message box in Windows Forms?
I only want the secondary console window to hold IDs (that will be hard coded into the application) So the user does not have to keep returning to the main menu to check available IDs
If so how would you go about it?
Many Thanks
Yes, you can do it.
The solution is actually very simple - our process can start a new helper child-process, so the helper process will display whatever our process sends it. We can easily implement such a solution with pipes: for each new console (that I'll call logger), we'll open a pipe, and execute a Console-Helper application - the role of this application is very simple, it will print everything sent through the pipe. Check out this article Multiple consoles for a single application for details (contains the source code).
In the code, it implement a console class CConsoleLogger, then you can create multiple console windows like:
CConsoleLogger another_console;
another_console.Create("This is the first console");
another_console.printf("WOW !!! COOLL !!! another console ???");
And you will get something like:
Take a look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms682528(v=vs.85).aspx for instructions for creating a console window.
Nop
A process can be associated with only one console.
AllocConsole

Win32 application with console output and without new window

I'd like to create a tool that can either act as command line (display some console output based on input parameters), or display a window, based on input parameters.
I'm using MSV2012 with C++, and it seems you have to 'choose' between console and window app.
I know the net is filled with samples which use AllocConsole() and redirect std::out, but it doesn't make it feel like a command line application : calling the exe from the windows console will open a new window with the console output...
Is there a way to have it use the current console window instead of allocating a new one?
If not possible, I'll make 2 applications instead, but that's a pity..
Someone else may have a more authoritative answer, but I don't believe it's supported.
The usual workaround is to create a Windows app, but have a command-line wrapper that launches it from the CLI (and provides a channel for communicating with the original console).
It's not technically supported but I found a good solution by getting a snapshot for the current process, finding the parent process, attaching to it's console if it's a console app or creating one with AllocConsole, redirecting the output, getting the thread of the parent process if it's cmd.exe and suspending it, resuming it just before I exit my app

Symbian simulate keyboard input

I have created a Qt background task that generates text on account of user input. My task runs when a text input field is open, what I now need is a way to insert text into the input of whatever application is currently open. I have looked at key press simulation but I cannot find a method that works.
Do you gave any idea what I can do?
PS. This is for Symbian^3(Belle) and Qt as well as Symbian C++ code will work.
On way to do it is
RWsSession sess=CCoeEnv::Static()->WsSession();
sess.SimulateKeyEvent(RFB::GetKeyEvent(code,ETrue));
User::After(200000);
sess.Flush();

Open console inside gui application

I'm trying to create a program in C++, which open with him, within the form, the CMD, so that I can run a program within the CMD that is inside the program. As an example, in this photo:
I found some examples, but could not implement them in code, so, I ask your help... To be more precise, I want to create a function in a dll, so I can call this CMD, starting from any language
basically an embedding a Console
I see two methods:
Write your own console widget and pass all entered command to the std::system command
Do what is described in How to open a console window in a Win32 application

How to send input to hidden program c++?

So my question is how to send some comands or input from one (c++) program to another if hi is on hidden mode? For example I want to open some text file in notepad with function WinExec("notepad", 0); and than want to print conetent of file, I make handle to that file, make sendinput with CTRL+P, and the window of printig show up,.... I want to make all that proces hidden from user, is it possible?
There're many ways to do it. You can open notepad on a separate desktop. If you run notepad with SW_HIDDEN it would also not show the window, and then you can use windows hooks to hook the creation of print window and ShowWindow() it to hidden.
But why all the hassle? If you don't need notepad's UI, why not just print the file yourself?