public static extern bool WriteConsoleOutputW( SafeFileHandle consoleFileHandle, CharAndColor[] buffer, COORD bufferWidthHeight, COORD offsetXY, ref ConsoleRegion consoleRegion );
public static void SelfTest() { SafeFileHandle h = OpenConsole(); int width = Console.WindowWidth; int height = Console.WindowHeight; if (!h.IsInvalid) { CharAndColor[] buf = new CharAndColor[width * height]; ConsoleRegion rect = new ConsoleRegion() { StartX = 0, StartY = 0, EndX = (short)width, EndY = (short)height }; var chars = Encoding.ASCII.GetBytes("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); var r = new Random(123); for (int background = 550; background >= 0; background--) { for (short x = 0; x < width; x++) { for (short y = 0; y < height; y++) { int xy = y * width + x; buf[xy].Attributes = SetColors(r.Next(16), 0); buf[xy].Char.AsciiChar = chars[r.Next(chars.Length)]; } } // this is the flush, to flush a region of a buffer to the screen bool b = WriteConsoleOutputW(h, buf, new COORD() { X = (short)width, Y = (short)height }, // buffer size new COORD() { X = 0, Y = 0 }, // where on the actual console will we be writing. ref rect); } } }