static extern bool WriteConsoleOutput( // SafeFileHandle hConsoleOutput, IntPtr hConsoleOutput, CharInfo[] lpBuffer, Coord dwBufferSize, Coord dwBufferCoord, ref SmallRect lpWriteRegion);
private CharInfo[] GetBufferDiff(CharInfo[] screenBuffer, out SmallRect smallRect) { try { var rect = new SmallRect { Left = 0, Top = 0, Right = (short)graphics.Width, Bottom = (short)graphics.Height }; smallRect = rect; if (previousScreenBuffer == null || previousScreenBuffer.Length != screenBuffer.Length) { return(screenBuffer); } for (var y = 0; y < graphics.Height; y++) { for (var x = 0; x < graphics.Width; x++) { var index = y * graphics.Width + x; var c1 = screenBuffer[index]; var c2 = previousScreenBuffer[index]; if (c1.Attributes != c2.Attributes || c1.UnicodeChar != c2.UnicodeChar) { return(screenBuffer); } } } return(null); } finally { previousScreenBuffer = new CharInfo[screenBuffer.Length]; screenBuffer.CopyTo(previousScreenBuffer, 0); } }