How can i capture the screen without the Form?

前端 未结 1 1446
无人共我
无人共我 2021-01-06 22:58

This is a class i\'m using to capture my screen and mouse cursour as screenshot. But i want to make somehow that if the Form is in the middle of the screen don\'t capture it

相关标签:
1条回答
  • 2021-01-06 23:00

    Um.. Hide the form?

    this.Visible = false; and THEN run the screenshot method.

    Like this:

    protected Bitmap TakeScreenshot(bool cursor)
    {
       Bitmap bitmap;
       this.Visible = false;
       bitmap = CaptureScreen(cursor);
       this.Visible = true;
       return bitmap;
    }
    

    and use it in your code the way you wanted:

     private void timer1_Tick(object sender, EventArgs e)
     {
        using (bitmap = (Bitmap)ScreenCapture.TakeScreenshot(true))
        {
            ffmp.PushFrame(bitmap);
        }       
     }
    
    0 讨论(0)
提交回复
热议问题