title: How to capture active windows on desktop by vb.net?
body: <p>I'm using this code to capture desktop </p>
  
  <pre><code>Private Function cc() As Bitmap
      Dim s As Screen = Screen.PrimaryScreen
      Dim img As New Bitmap(s.Bounds.Width, s.Bounds.Height)
      Dim gr As Graphics = Graphics.FromImage(img)
      gr.CopyFromScreen(s.Bounds.Location, Point.Empty, s.Bounds.Size)
      Return img
  End Function
  
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Try
          Me.PictureBox1.Image = cc()
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  End Sub
  </code></pre>
  
  <p>But now I want to capture only the active screen, how can I do that?</p>
  
  <p>Regards,,,,,</p>