|
-
May 20th, 2001, 10:20 AM
#1
Thread Starter
Lively Member
How to Detect a Key Pressed from Outside my VB App like Getting the Cursor Positon
Hi,
With the GetCursorPos API we can get the Position of the Cursor even when a VB APP is not in Focus. ie., wherever the mouse is moved the Mouse Position can be traced with the GetCursorpos API. Is there any API to trace out the Keyboard hit events and trace the value of Key Pressed. Say suppose if the Enter Key is Pressed I should get a value like the KeyAscii Value. Is it Possible... If Possible then can anyone explain it to me with a working Example... I will be greatly thankful to you.
-
May 20th, 2001, 11:33 AM
#2
New Member
You can use the GetAsyncKeyState() API Function.
Example:
Code:
Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Dim State as Integer
State = GetAsyncKeyState(vbKeyH)
If State And &H8000 Then
'Key is pressed
Else
'H Key is not pressed
End If
-
May 20th, 2001, 01:25 PM
#3
The hook method is more accurate, but the disadvantage, as Vlatko pointed out, is that it's harder to do.
-
May 21st, 2001, 02:18 AM
#4
Thread Starter
Lively Member
It's giving a Error, Invalid Addressof TimerProc...
Hi Vlatko,
I tried your Program, It's giving me a error called Invalid AddressOf usage (something like that). What should I do now. And from where can I get the Value of Keypressed and in What Format. Whether Keycode or KeyAscii, Or anyother Different value. Please help me...
Anyway thanks for ur code....
-
May 21st, 2001, 03:57 AM
#5
Frenzied Member
Note that the first code (with the TimerProc) has to be in a module and not in a form.
Put this declarations in the module also.
Code:
Public Cnt As Long, sSave As String, sOld As String, Ret As String
The value you get is a character not ASCII code but the letter.
-
May 21st, 2001, 08:59 AM
#6
Thread Starter
Lively Member
How about Alt, Ctrl and Shift Keys...
Hi Vlatko,
If I pressed the Normal Character Keys and the Number Keys then it'll give a Character then how about about the Mask keys namely Alt, Ctrl and Shift Keys. Also how about the Function Keys... Have any Idea....
-
May 21st, 2001, 09:05 AM
#7
Frenzied Member
Search the web and the VB sites. There is a lot of code for fully functional keyloggers.
-
May 21st, 2001, 09:45 AM
#8
Planet-Source-Code.com has some examples. Click here to view them.
-
May 21st, 2001, 10:02 AM
#9
Thread Starter
Lively Member
Thanks Megatron I got It....
Hi Megatron,
I got them and thanks for it. I've not yet tried them. After trying I'll contact you. Can u give ur mail id. It would be easy for me to contact you there.
Regards
-
May 23rd, 2001, 01:57 PM
#10
Lively Member
Get window name?
Is there any way yo get the name of the window text is typed into?
-
May 23rd, 2001, 02:29 PM
#11
Re: Thanks Megatron I got It....
Originally posted by lvramanan
Hi Megatron,
I got them and thanks for it. I've not yet tried them. After trying I'll contact you. Can u give ur mail id. It would be easy for me to contact you there.
Regards
Sure, it's [email protected]
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
|