שתף באמצעות


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

Question

Tuesday, June 27, 2017 6:35 AM

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,,,,

All replies (1)

Tuesday, June 27, 2017 6:48 AM ✅Answered

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

Asked and answered here:
http://www.vbforums.com/showthread.php?669866-RESOLVED-Screenshot-of-Active-Window-Area

It's a bit old, but should be still usable.