Taking a screenshot using c# with out including task bar.

痞子三分冷 提交于 2019-12-02 07:51:07

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!