get handle for console window C#
using System; using System.Runtime.InteropServices; namespace MyConsoleApp { static class Program { [DllImport("user32.dll")] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); static void Main(string[] args) { // make sure to put this after any assignments to Console.Title // so that the handle to the Console Window will be valid IntPtr consolePtr = FindWindow(null, Console.Title); } } }