Dear Friends,
I want to record all keys when key pressed in anywhere. It is possible?
please help me.
Thanx.
Dear Friends,
I want to record all keys when key pressed in anywhere. It is possible?
please help me.
Thanx.
Here is a simple way without subclassing.
Put code in a module:
then use a timer to call this.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
"Today's mighty oak is just yesterday's nut,
that held its ground."
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.
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."
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."
Thank you Alan.
I am trying to do that.
Thanx.
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."