void PullScreen() { try { do { ConsoleUtilities.CONSOLE_SCREEN_BUFFER_INFO bufferinfo; if (ConsoleUtilities.GetConsoleScreenBufferInfo(consolestdout, out bufferinfo) == false) { Debug.WriteLine("GetConsoleScreenBufferInfo() failed"); Thread.Sleep(1000); continue; } Push_Stdio_StdOut std = new Push_Stdio_StdOut(); std.WindowsY = (bufferinfo.srWindow.Bottom - bufferinfo.srWindow.Top) + 1; std.WindowsX = (bufferinfo.srWindow.Right - bufferinfo.srWindow.Left) + 1; ConsoleUtilities.SMALL_RECT r = bufferinfo.srWindow; ConsoleUtilities.COORD csz = new ConsoleUtilities.COORD(); csz.X = (short)std.WindowsX; csz.Y = (short)std.WindowsY; ConsoleUtilities.COORD ccoord = new ConsoleUtilities.COORD(); ccoord.X = 0; ccoord.Y = 0; ConsoleUtilities.CHAR_INFO2[] info = new ConsoleUtilities.CHAR_INFO2[csz.X * csz.Y]; if (ConsoleUtilities.ReadConsoleOutput(consolestdout, info, csz, ccoord, ref r) == false) { Debug.WriteLine("ReadConsoleOutput() failed"); Thread.Sleep(1000); continue; } std.CursorX = bufferinfo.dwCursorPosition.X - bufferinfo.srWindow.Left; std.CursorY = bufferinfo.dwCursorPosition.Y - bufferinfo.srWindow.Top; std.SessionID = SessionID; std.State = PushStdoutState.OK; std.Data = info; if (BufferChanged(std) == true) { consoleendSetResultStacked.SetResultStacked(std); lastbuffer = std; Thread.Sleep(10); //a trick to "skip" some pages, due some intense scrolling } else { Thread.Sleep(100); //polling principle :-( } } while (consoleproc.HasExited == false); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); } try { Push_Stdio_StdOut std = new Push_Stdio_StdOut(); std.State = PushStdoutState.End; consoleendSetResultStacked.SetResultStacked(std); } catch { } }