public static void CaptureApplications(List <IntPtr> captureprocess, string fileLocation, string FileName)
        {
            var      imagesize          = getCaptureSize(captureprocess);
            var      MainbmpImage       = new Bitmap(imagesize.width, imagesize.height, PixelFormat.Format32bppArgb);
            Graphics Maingraphics       = Graphics.FromImage(MainbmpImage);
            int      CurrentMotionRight = 0;


            foreach (IntPtr item in captureprocess)
            {
                var rect = new User32.Rect();
                User32.GetWindowRect(item, ref rect);
                int      currentWidth  = rect.right - rect.left;
                int      currentHeight = rect.bottom - rect.top;
                var      bmp           = new Bitmap(imagesize.width, imagesize.height, PixelFormat.Format32bppArgb);
                Graphics graphics      = Graphics.FromImage(bmp);
                System.Threading.Thread.Sleep(200);
                User32.SetForegroundWindow(item);
                System.Threading.Thread.Sleep(100);
                graphics.CopyFromScreen(rect.left, rect.top, 0, 0, new Size(currentWidth, currentHeight), CopyPixelOperation.SourceCopy);
                Maingraphics.DrawImage(bmp, new Point(CurrentMotionRight, 0));
                CurrentMotionRight = CurrentMotionRight + currentWidth;
            }
            string directoryToCreate = string.Concat("c:\\users\\", Environment.UserName, "\\Screen Shooter Projects\\", fileLocation, "\\");

            Directory.CreateDirectory(directoryToCreate);
            MainbmpImage.Save(string.Concat(directoryToCreate, FileName, ".png"), ImageFormat.Png);
        }
        public static ImageSize getCaptureSize(List <IntPtr> captureprocess)
        {
            foreach (IntPtr item in captureprocess)
            {
                User32.ShowWindow(item, 3);
                System.Threading.Thread.Sleep(200);
            }
            int maxHeight = 0;
            int sumWidth  = 0;

            foreach (IntPtr item in captureprocess)
            {
                var rect = new User32.Rect();
                User32.GetWindowRect(item, ref rect);
                sumWidth = sumWidth + rect.right - rect.left;
                if ((rect.bottom - rect.top) > maxHeight)
                {
                    maxHeight = (rect.bottom - rect.top);
                }
            }
            return(new ImageSize()
            {
                width = sumWidth,
                height = maxHeight,
            });
        }