|
-
Feb 17th, 2001, 04:59 AM
#1
Thread Starter
Lively Member
Dear Friends,
I want to record all keys when key pressed in anywhere. It is possible?
please help me.
Thanx.
-
Feb 17th, 2001, 06:19 AM
#2
Hyperactive Member
Here is a simple way without subclassing.
Put code in a module:
Code:
Option Explicit
Public KeypressArray(Max) as Byte
Private ArrPos as long
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Public Function KeyInput() As Byte
Dim i As Integer
'Check for keyboard input
For i = 0 To 255
If (GetAsyncKeyState(i) And &H8001) <> 0 Then
ArrPos = ArrPos + 1
KeypressArray(ArrPos) = i
KeyInput = i
Exit Function
End If
Next i
KeyInput = 0
End Function
then use a timer to call this.
"Today's mighty oak is just yesterday's nut,
that held its ground."
-
Feb 17th, 2001, 06:27 AM
#3
Thread Starter
Lively Member
Thank You. But...
Dear Alan777,
Thanx for your help.
Now I am trying that.
But it says (Max) ' Variable Not Found'
(Public KeypressArray(Max) As Byte
Private ArrPos As Long)
Thanx Again Alan777.
-
Feb 17th, 2001, 06:31 AM
#4
Hyperactive Member
I should have commented that.
You need to put a number there. The maximum number of keystrokes that you think you will need to record.
"Today's mighty oak is just yesterday's nut,
that held its ground."
-
Feb 17th, 2001, 06:42 AM
#5
Hyperactive Member
I just tried it out to see what happens. You will need to do some fine tuning on it. Using the timer on an interval of 100 it works ok, but if you hold a key down, you will get this repeating in the array. Also, when the form is loading, sometimes some garbage numbers come out, so your array would pick them up too. Just looking at it a bit, subclassing might be the best bet.
"Today's mighty oak is just yesterday's nut,
that held its ground."
-
Feb 17th, 2001, 06:55 AM
#6
Thread Starter
Lively Member
Thank you Alan
Thank you Alan.
I am trying to do that.
Thanx.
-
Feb 17th, 2001, 07:24 AM
#7
Hyperactive Member
Check out Darkangel's thread too. Lord Orwell is going to show us the best way to do this.
"Today's mighty oak is just yesterday's nut,
that held its ground."
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
|