Код: Выделить всё
internal static class Screenshot
{
[StructLayout(LayoutKind.Sequential)]
internal struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
[DllImport("user32.dll")]
public static extern bool PrintWindow(IntPtr hWnd, IntPtr hdcBlt, uint nFlags);
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
public static Bitmap CaptureGameProcess( string windowTitle, string screenShotSavePath)
{
IntPtr handle = FindWindow(null, windowTitle);
// Get the dimensions of the window
RECT rect;
GetWindowRect(handle, out rect);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
// Create a bitmap to store the screenshot
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
// Capture the window
using (Graphics gfxBmp = Graphics.FromImage(bmp))
{
IntPtr hdcBitmap = gfxBmp.GetHdc();
PrintWindow(handle, hdcBitmap, 0);
gfxBmp.ReleaseHdc(hdcBitmap);
}
return bmp;
}
}

Кислород не включен — здесь просто белое изображение

Скриншот игры Half-Life показывает просто черное окно.
Подробнее здесь: https://stackoverflow.com/questions/792 ... rintwindow