Question

How to take screenshot using c# with out including task bar.I tried some codes but it takes whole screen.

Was it helpful?

Solution

try with Screen.PrimaryScreen.WorkingArea it gives you the screen excluding task bar

Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width,
                           Screen.PrimaryScreen.WorkingArea.Height,
                           PixelFormat.Format32bppArgb);

Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);


gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.WorkingArea.X,
                            Screen.PrimaryScreen.WorkingArea.Y,
                            0,
                            0,
                            Screen.PrimaryScreen.WorkingArea.Size,
                            CopyPixelOperation.SourceCopy);

bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);

Screen.WorkingArea Property

Gets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top