本文介绍了使用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 Property
这篇关于使用c#截屏,但不包括任务栏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!