简体   繁体   English

使用c#截屏,但不包括任务栏。

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

如何在不使用任务栏的情况下使用c#截屏。

try with Screen.PrimaryScreen.WorkingArea it gives you the screen excluding task bar 尝试使用Screen.PrimaryScreen.WorkingArea它为您提供除任务栏之外的屏幕

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 Screen.WorkingArea属性

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. 工作区域是显示器的桌面区域,不包括任务栏,停靠的窗口和停靠的工具栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM