Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public UserRect(UserRect Rectangle) : this(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom)
 {
 }
Exemplo n.º 3
0
 public static extern IntPtr GetWindowRect(IntPtr hWnd, ref UserRect rect);
Exemplo n.º 4
0
 public bool Equals(UserRect Rectangle)
 {
     return(Rectangle.Left == _Left && Rectangle.Top == _Top && Rectangle.Right == _Right && Rectangle.Bottom == _Bottom);
 }