Solved

Key loger

Posted on 1998-10-22
9
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month4 days, 8 hours left to enroll

636 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