0

I want to capture only some part of desktop screen. for example I've opened 4,5 different window explorer, browsers, some MS office files and other stuff. and I want to take screenshot which only include some of them(windows). Not All windows.

 string appPath = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory) + @"\screenshots\";
            string imgName = name + DateTime.Now.Ticks + @".JPEG";
            Bitmap memoryImage = null;
            Graphics memoryGraphics = null;

            int width = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenWidth);
            int height = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenHeight);

            System.Drawing.Size s = new System.Drawing.Size(width, height);
            string str = "";
            try
            {
                str = appPath + imgName;
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message.ToString());
            }
            using (memoryImage = new Bitmap(width, height))
            {
                using (memoryGraphics = Graphics.FromImage(memoryImage))
                {
                    memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);
                    memoryImage.Save(str);
                }
            }
            memoryImage.Dispose();
            memoryGraphics.Dispose();

I'm using above code, which simple give me screenshot of my desktop.

Nafees Abbasi
  • 367
  • 1
  • 4
  • 12
  • 1
    If you know the location of the desired window, you can remove the other parts from the screenshot. – wimh Apr 21 '16 at 08:42
  • I know the location of desired windows. hight,width, but how i can remove undesired windows? – Nafees Abbasi Apr 21 '16 at 09:29
  • Possible duplicate of [Capture screenshot of active window?](http://stackoverflow.com/questions/1163761/capture-screenshot-of-active-window) – wimh Apr 21 '16 at 10:15
  • No it's not similar to that scenario. I want to capture some desire windows – Nafees Abbasi Apr 21 '16 at 12:21

0 Answers0