使用c#截屏,但不包括任务栏。 [英] Taking a screenshot using c# with out including task bar.

查看:140
本文介绍了使用c#截屏,但不包括任务栏。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不包含任务栏的情况下使用c#截屏。我尝试了一些代码,但它占用了整个屏幕。

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

推荐答案

尝试使用 Screen.PrimaryScreen.WorkingArea ,它为您提供不包括任务栏的屏幕

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属性

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.

这篇关于使用c#截屏,但不包括任务栏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆