Solved

Key loger

Posted on 1998-10-22
9
219 Views
Last Modified: 2010-04-30
How do you get a form that does not have focus to "see" what keys are being pressed. I want to make a key loger. I have done this and I tryed to use it but as soon as the form lost focus it stoped logging keys pressed. Please help.
0
Comment
Question by:rpg_rpg
  • 5
  • 4
9 Comments
 

Author Comment

by:rpg_rpg
ID: 1441116
Edited text of question
0
 
LVL 1

Expert Comment

by:Geffl
ID: 1441117
I needed the same functions in my printscreen utility. The API-Call you need is GetAsyncKeyState ...

Here is my example:
Paste this code in a module

Public Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Public Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Type KeyboardBytes
    kbByte(0 To 255) As Byte
End Type

Public kbArray As KeyboardBytes
Public Const VK_SNAPSHOT = &H2C
Public Const VK_ALT = &H12

Paste this code in the form_load part

    Do
        If (GetAsyncKeyState(VK_SNAPSHOT)) Then
            If (GetAsyncKeyState(VK_ALT)) Then
                MsgBox "Alt And Print pressed"
            Else
                MsgBox "Print pressed"
            End If
            kbArray.kbByte(VK_SNAPSHOT) = 0
            kbArray.kbByte(VK_ALT) = 0
            SetKeyboardState kbArray
        End If
        DoEvents
        Sleep 25
    Loop

Don´t forget the DoEvents and the sleep, because the endless-loop this would be important for the performance of you app.
0
 

Author Comment

by:rpg_rpg
ID: 1441118
This is really close. But I am not real versed in API. If you could please tell me how to "see" a certen key other then print and alt+print. What is &H2C  and &H12 mean and how did you get those values? I hope you are not mad at my slowness. I know this is a good example. I just don't get it. Thanks...
0
 
LVL 1

Expert Comment

by:Geffl
ID: 1441119
The hexadecimal values are the constants for virtual keys. If you can´t find the definition of the virtual keys in your help-file or the api-text viewer (in constants) post your e-mail adress and i´ll mail it to you.

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:rpg_rpg
ID: 1441120
Gee... now I really feal dumb... I looked in both places and loaded all aviable files with the api-text viewer and could not find anything at all. Please send email to
Xer_Soft@hotmail.com        

If I had any more points to give you I would. Thanks again...
0
 
LVL 1

Expert Comment

by:Geffl
ID: 1441121
I just sent you the definitions...
0
 

Author Comment

by:rpg_rpg
ID: 1441122
Thanks a lot. I got it to work! Sorry for all the extra work I put you through. You did great. If there was a higher grade or I had more points I would give them to you!!!! OH... You need to answer with some thing... Go ahead.
0
 
LVL 1

Accepted Solution

by:
Geffl earned 200 total points
ID: 1441123
with some thing...

joke!

fine that it works!
0
 

Author Comment

by:rpg_rpg
ID: 1441124
Adjusted points to 205
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now