如何截取完整桌面Windows c#

How to take screenshot of complete desktop Windows c#

以下代码仅截取桌面 window。我的期望是截取任务栏和用户可见的所有内容。

如有任何帮助,我们将不胜感激

''' {

       //Creating a new Bitmap object

      Bitmap captureBitmap = new Bitmap(1024, 768, PixelFormat.Format32bppArgb);

   
     //Bitmap captureBitmap = new Bitmap(int width, int height, PixelFormat);

     //Creating a Rectangle object which will  

     //capture our Current Screen

     Rectangle captureRectangle = Screen.AllScreens[0].Bounds;



     //Creating a New Graphics Object

     Graphics captureGraphics = Graphics.FromImage(captureBitmap);



    //Copying Image from The Screen

    captureGraphics.CopyFromScreen(captureRectangle.Left,captureRectangle.Top,0,0,captureRectangle.Size);



    //Saving the Image File (I am here Saving it in My E drive).

    captureBitmap.Save(@"E:\Capture.jpg",ImageFormat.Jpeg);



    //Displaying the Successfull Result



    MessageBox.Show("Screen Captured");

}

'''

这对你来说应该没问题,重复问题 here

Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, 
                                    Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);