Using AttachConsole, while the process I've attached with is running and spewing, I can still type and run other commands.
My program runs in either a form, or from command line. If started with arguments it runs in the command window. I use AttachConsole(-1) to attach my process to command window I called from. It works great, I get all my output spew from my process.
However, the console still processes user input from the keyboard, whatever I type, for instance, if I type 'cls' and hit enter, the output will be wiped. How can I block user input to the console while the process is running?
This may not be elegant based on what you are doing, but do a Kill() on the console after attaching it and it will continue to get output from your other process. Example Windows Forms code below, add your own bells and whistles:
I found a little cleaner solution is just to send an extra "Enter" to the console after your program exits:
Not quite sure about this but is AllocConsole instead of AttachConsole not a more easy approach for this problem?