How could I write to the standard output of some already open console? I find the console I need with this piece of code:
IntPtr ptr = GetForegroundWindow();
If you just want to write to the console that's used by some other app, then you can use the following - you'll need to use P/Invoke to do the first step:
Having said that, even though you can do this, it's not necessarily a good idea to do so. There's nothing to stop the original process from writing to the console while you are doing likewise, and the output from both getting mixed-up, depending on how the processes are doing buffering. If you want to do something like notify the user of something regardless of which window is active, there may be a better way of doing that.