Advertisement
hungvb

[VB] Screen Capturing Program Tutorial

Sep 23rd, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.47 KB | None | 0 0
  1. Public Class Form1
  2.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  3.         Dim bounds As Rectangle
  4.         Dim screenshot As System.Drawing.Bitmap
  5.         Dim graph As Graphics
  6.         bounds = Screen.PrimaryScreen.Bounds
  7.         screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
  8.         graph = Graphics.FromImage(screenshot)
  9.         graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
  10.         PictureBox1.Image = screenshot
  11.         Timer1.Enabled = False
  12.         Me.Opacity = 100
  13.     End Sub
  14.  
  15.     Private Sub ToolStripStatusLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripStatusLabel1.Click
  16.         Me.Opacity = 0
  17.         Timer1.Enabled = True
  18.     End Sub
  19.  
  20.     Private Sub ToolStripStatusLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripStatusLabel2.Click
  21.         Dim savefiledialog1 As New SaveFileDialog
  22.         Try
  23.             savefiledialog1.Title = "Save File"
  24.             savefiledialog1.FileName = "Save As..."
  25.             savefiledialog1.Filter = "JPEG |*.jpeg"
  26.             If savefiledialog1.ShowDialog() = DialogResult.OK Then PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
  27.         Catch ex As Exception
  28.             'Do Nothing
  29.         End Try
  30.     End Sub
  31. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement