|
-
Jul 17th, 2000, 12:16 AM
#1
Thread Starter
Hyperactive Member
Code not slow...
I noticed that the code wasn't slow... it's working good.. however... it captures the keys when they are RELEASED and not PRESSED which is what I want...
This is perfect for users who type with two fingers on their keyboard. However, more experienced keyboard-users use alot more fingers and they press the next key BEFORE releasing the first one and in some cases the third key also before even releasing the first one (the finger wasn't quick enough to lift before the other two pushed other keys) and release in NOT the same order.
So when I type 'hello'
it captures: ehlol (or sometimes 'helo')
Does anyone know how to improve this code or have any better suggestion? I've looked into C++ examples with keyboard hooking, althoug, I know zip about C so that didn't help me.. and vb could create a reference to it's dll either so I guess it's just doing something vb.
ANyone know?
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jul 17th, 2000, 05:45 AM
#2
Thread Starter
Hyperactive Member
I tried this code too:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function ToAscii Lib "user32" (ByVal uVirtKey As Long, ByVal uScanCode As Long, lpbKeyState As Byte, lpwTransKey As Long, ByVal fuState As Long) As Long
Private Const VK_SHIFT = &H10 'Used by Win9x
Private Const VK_LSHIFT = &HA0 'Used by NT
Private Const VK_RSHIFT = &HA1 'Used by NT
Private Sub Form_Load()
Timer1.Interval = 50
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim iKey As Integer
Dim iAsc As Long
Dim bKeys(255) As Byte
For iKey = 0 To 255
'Use GetAsyncKeyState to Monitor Keypress From Anywhere in the O/S.
If GetAsyncKeyState(iKey) And iKey <> VK_LSHIFT And iKey <> VK_RSHIFT And iKey <> VK_SHIFT Then Exit For
Next
If iKey < 256 Then
'Get the Current Keyboard State For the Shift Keys Etc..
Call GetKeyboardState(bKeys(0))
'Conver the Key to it's ASCII Equivilant
Call ToAscii(iKey, 0&, bKeys(0), iAsc, 0&)
If iAsc Then
'Store Keypress to Log Here
Debug.Print Chr(iAsc);
End If
DoEvents
While GetAsyncKeyState(iKey)
'Wait for Key to be Released
Wend
End If
End Sub
but the same problem there, when typing fast, I recieve the characters in the wrong order.... ;(
Anyone have any idea of how to solve this problem?
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jul 17th, 2000, 08:42 AM
#3
You said something about Keyboard hooking before: Try looking into KeyboardProc. I'm not entirely familiar with it. Here is an article that might help you
-
Jul 17th, 2000, 09:18 AM
#4
Hyperactive Member
I made a key logger in windows, it logs all keys that were pressed by the user, and it works fine with me. I think it captures keystrokes even if an advanced user is working, if you'd like i can mail it to you.
-
Jul 17th, 2000, 04:31 PM
#5
Thread Starter
Hyperactive Member
Sure, mail it
And I'll see if it can help me 
(The source is also highly appreciated)
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jul 17th, 2000, 04:41 PM
#6
Thread Starter
Hyperactive Member
I tried looking into the KeyboardProc thing and it seemed to be usefull, however, when running the example program on the page, VB crashed.
After restarting computer, doing it all over, running it again, crashing it agian.
VB crashes somewhere in Kernel32.dll which I believe put a stop to what it thought was dangerous thing that vb was doing.
(if I compile it, and then run it... then only the program crashes, after clicking close, it crashes again, and keeps crashing about 5 or 6 times before finally windows crashes instead and the computer hangs... Anyone with less dangerous ideas?)
[Edited by Rodik on 07-17-2000 at 05:44 PM]
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jul 17th, 2000, 04:58 PM
#7
Did you remember to UnHook it?
-
Jul 17th, 2000, 05:01 PM
#8
Thread Starter
Hyperactive Member
Yeah, remembered to unhook it, the problem is I never get the chance to hook it from the begininng because VB crashes when pushing F5, r who knows.. maybe some of the code is wrong (which I checked about 4 times now) and it stops to debug and because the keyboard is hooked to that program which ceases to exist at debug time, it crashes.
Besides, when it DID run, it only captured keyboard-events when the program itself had the focus (and not the whole system).
*sigh*
Some must know a way to do this??
[Edited by Rodik on 07-18-2000 at 12:28 AM]
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jul 17th, 2000, 11:33 PM
#9
Thread Starter
Hyperactive Member
How uninteresting can a thread be?
Isn't there ANYONE from those thousands and thousands of members that this board has any knowledge on this matter?
Is it really so difficult?
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jul 19th, 2000, 04:50 AM
#10
Well ....
You look frustrated, now.
While learning C, I came across something like TSRs, i.e. memory resident programs written in C. I think this info can help you.
The TSR use something like an Interrupt Vector Table to interrupt various signals that your OS would otherwise receive and act upon. I believe most of the Anti-Virus softwares that provide some kind of hard disk locking (disallowing any write operations on your hdd) also use something like this. If you can get your hands on such stuff, you can trap keystrokes also. The TSR would simply intercept the keyboard messages going to the OS and you would be able to catch them before Windows.
By the way, all you people are typing it so wide, it does not fit onto my screen. Any ideas?
-
Aug 3rd, 2000, 08:44 PM
#11
here is a keylogger....
it works, not very good though....
add a timer and a textbox to a form, make the textbox MultiLine(set the multiline property to true) and paste this in, it works crappy, but it works
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
For i = 13 To 122
If GetAsyncKeyState(i) <> 0 Then
Text1 = Text1 & LCase(Chr(i))
End If
Next
End Sub
set the timer's interval to 100
-
Aug 3rd, 2000, 09:03 PM
#12
Hacking? ...
Well no offence meant at anybody.
But, we had a case of a hacker (or cracker) who got hold of a program to capture keystrokes. He used (and still uses) this program in cybercafes to read the mail that other people type (not to mention loginnames and passwords and credit card numbers.)
Rodik, are you an aspiring hacker?
-
Aug 4th, 2000, 07:10 AM
#13
This one kept me sleepless for weeks
I have recently written a macro application that required just this sort of key logging.
At the start of the year I starting hunting around for a decent routine. I kept downloading different examples as competition between programmers began to produce better an better routines.
Most would still miss a key now and again.
Then I did a search on http://www.planetsourcecode.com on the phrase 'Key logger'. One of the examples was written by
Konstantin Tretyakov entitled 'A complete keylogger in delphi'
It turns out this is a small Delphi DLL which creates a Key Hook. The dll is free and comes with an example VB program on how to use the dll.
It is by far the best routine I have seen. I am not sure on its exact technical details but it does the job.
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
|