【问题标题】:Taking a screenshot using c# with out including task bar.使用 c# 截取屏幕截图,不包括任务栏。
【发布时间】:2014-02-09 12:36:23
【问题描述】:

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

【问题讨论】:

    标签: c# c#-2.0


    【解决方案1】:

    尝试使用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

    获取显示的工作区域。工作区是桌面 显示区域,不包括任务栏、停靠的窗口和停靠的 工具栏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-20
      • 1970-01-01
      • 1970-01-01
      • 2014-09-26
      相关资源
      最近更新 更多