none
How to Capture screenshot of active windown by vb.net? RRS feed

  • Question

  • How to Capture screenshot of active windown by vb.net?

    I am making a screen capturing application and everything is going fine. All I need to do is capture the active window and take a screenshot of this active window.
    Does anyone know how I can do this?

    Now I'm using this code to take a screenshot of desktop

    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

    Regards,,,,

    Tuesday, June 27, 2017 6:35 AM

Answers