public void ReadOutput(ConsoleApi.CHAR_INFO[] Buffer, ConsoleApi.COORD BufferSize, ConsoleApi.COORD BufferCoord, ref ConsoleApi.SMALL_RECT Region) { if (!ConsoleApi.ReadConsoleOutput(hConOut, Buffer, BufferSize, BufferCoord, ref Region)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } }
public void SetSize(ConsoleApi.COORD Size) { if (!ConsoleApi.SetConsoleScreenBufferSize(hConOut, Size)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } }
public ConsoleApi.CONSOLE_SCREEN_BUFFER_INFO GetInfo() { ConsoleApi.CONSOLE_SCREEN_BUFFER_INFO ret; if (!ConsoleApi.GetConsoleScreenBufferInfo(hConOut, out ret)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } return(ret); }
public void Write(ConsoleApi.INPUT_RECORD[] Inputs) { UInt32 nWritten = 0; if (!ConsoleApi.WriteConsoleInput(hConIn, Inputs, (uint)Inputs.Length, out nWritten)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } if (nWritten != Inputs.Length) { throw new Exception("Not all inputs could be written to console."); } }
public ConsoleInput() { hConIn = CreateFileApi.CreateFile( "CONIN$", CreateFileApi.FileAccess.GenericRead | CreateFileApi.FileAccess.GenericWrite, CreateFileApi.FileShare.Read, IntPtr.Zero, CreateFileApi.CreationDisposition.OpenExisting, CreateFileApi.FileAttributes.Normal, IntPtr.Zero ); if (hConIn.IsInvalid) { throw new Win32Exception(Marshal.GetLastWin32Error()); } uint Mode; ConsoleApi.GetConsoleMode(hConIn, out Mode); ConsoleApi.SetConsoleMode(hConIn, (uint)(Mode & ~0x0001)); // Disable ENABLE_PROCESSED_INPUT so that Ctrl+C passes through. }