|
-
Jan 11th, 2002, 04:12 AM
#1
Thread Starter
Hyperactive Member
Capture keyboard input
Hello there, I need to make a program that can capture keyboard input from any window that has input focus. Anybody can help me out with some piece of code?
-
Jan 11th, 2002, 04:45 AM
#2
you'll need to look at the GetAsyncKeyState
Try the API guide download at www.allapi.net for a sample of this one
-
Jan 11th, 2002, 05:19 AM
#3
Frenzied Member
#If you are using WinNT4, Win2K or WinXP you can install a WH_KEYBOARD_LL hook that will receive keyboard event notifications for every keypress regardless of whether your application has focus or not...
To do this with the EventVB.dll :
Code:
'\\ In form declarations...
Dim WithEvents vbLink As EventVB.APIFunctions
Dim WithEvents vbKddHook As EventVB.EnumHandler
[COLOR=green]'\\ Start hook when form loads [COLOR]
Private Sub Form_Load()
Set vbLink = New APIFunctions
Set vbKbdHook = vbLink.EventhandlerLink
vbKbdHook.StartHook WH_KEYBOARD_LL, vbLink.ModuleHandle, 0
End Sub
[COLOR=green]'\\ Stop hook when form unloads [COLOR]
Private Sub Form_Unload()
vbKbdHook.StopHook WH_KEYBOARD_LL
End Sub
[COLOR=green]'\\ Process keyboard events [COLOR]
Private Sub vbKbdHook_HOOKPROCKEYBOARDLL(Action As EventVB.enHookCode, ByVal KeyState As Long, ByVal KeyStrokeInfo As EventVB.ApiKBDLLHOOKSTRUCT, lMsgRet As Long)
With KeyStrokeInfo
If .KeyReleased Then
Debug.Print .KeyNameText & " released"
End If
End With
End Sub
HTH,
Duncan
-
Jan 11th, 2002, 05:37 AM
#4
Further to the PM I just got...
Goto http://www.allapi.net/agnet/aanreg.php and download the program.
Search for "GetAsyncKeyState" down the left hand side and the right side will have some code under the Examples tab. Shove this into a new form & module & run it.
Follow the on screen instructions and this is basically the same as you're trying. By then changing this line in the sample :
to
Code:
Clipboard.Clear
Clipboard.SetText sSave
this will copy the text to the clipboard.
-
Jan 11th, 2002, 05:52 AM
#5
Thread Starter
Hyperactive Member
Thanx guys for the reply.
Thanx alex_read i got the sample code from allapi. That really helped me out!!!
-
Jan 11th, 2002, 05:52 AM
#6
Thread Starter
Hyperactive Member
Thanx guys for the reply.
Thanx alex_read i got the sample code from allapi. That really helped me out!!!
cheeers
vbud
-
Jan 11th, 2002, 10:37 AM
#7
Hyperactive Member
Watch out there, when you start using those keyboard hooks, some antivirus programs (specifically McAfee) will pick up your code as a virus.. a keystroke logger..
-mcd
[vbcode]
'*****************************
MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
'*****************************
[/vbcode]
-
Jan 14th, 2002, 01:17 AM
#8
Thread Starter
Hyperactive Member
Thanx MetallicaD i`ll try to keep that in mind!!!
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
|