Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Key loger

Posted on 1998-10-22
9
Medium Priority
?
232 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 

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 800 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Suggested Courses

926 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