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

↘锁芯ラ 提交于 2019-12-02 12:21:31

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/21655192/taking-a-screenshot-using-c-sharp-with-out-including-task-bar

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