public static Bitmap CaptureApplication(string procName) { var proc = Process.GetProcessesByName(procName)[0]; var rect = new UserRect(); GetWindowRect(proc.MainWindowHandle, ref rect); int width = rect.Right - rect.Left; int height = rect.Bottom - rect.Top; Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(bmp); graphics.CopyFromScreen(rect.Left, rect.Top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy); return(bmp); }
public UserRect(UserRect Rectangle) : this(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom) { }
public static extern IntPtr GetWindowRect(IntPtr hWnd, ref UserRect rect);
public bool Equals(UserRect Rectangle) { return(Rectangle.Left == _Left && Rectangle.Top == _Top && Rectangle.Right == _Right && Rectangle.Bottom == _Bottom); }