Solved

Key loger

Posted on 1998-10-22
9
221 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

16 Experts available now in Live!

Get 1:1 Help Now