How to Capture the Screen of your PC using VB.net
The code will teach how to capture the screen of your computer and then save it as picture file.
Output:
Code:
Public Class frmScreenCap
Private Sub btnCapture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCapture.Click
Me.Opacity = 0
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Timer1.Enabled = False
Me.Opacity = 100
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim savefile As New SaveFileDialog
Try
savefile.Title = "Save File"
savefile.FileName = "Save As"
savefile.Filter = "JPEG |*.jpeg"
If savefile.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(savefile.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
End Try
End Sub
End Class
How to Capture the Screen of your PC using VB.net
Reviewed by code-dev
on
11:59 AM
Rating:
No comments: