Code for Journal Hook or WH_KEYBOARD hook in order to log all keystrokes.

Posted on 2005-04-25
Last Modified: 2010-04-05

I have a huge program that I've constructed, and now I just need to add a form that detects system wide keystrokes. I saw a previous EE article that talked about journal hooks and wh_keyboard hook. Whats the difference? It seems like the journal hook does not require an outside dll? If so that would be great.

Heres what I need the code to do:
1) detect all keystrokes
2) determine the window that is receiving the keystroke (this should be simple)
3) be as simple as possible! I've seen source code that does all this crazy stuff...I just want it to be plain and simple so I could understand whats going on. For example theres code that retrieves the strokes in multiple ways, uses different languages (i dont know what thats about), etc etc...I just want it to log the keystroke in the simplest most efficient way.
4) It should be compatible with win xp for sure. And preferably also with win 98 and win me.
5) Im using delphi 7 if the version makes any difference.

If I could get this to actually run and things make sense to me, and its what Im looking for (not something Im just settling for), I will double the points.

Question by:createit
    LVL 12

    Accepted Solution


    Expert Comment

    Looks like your asking Peopel ot make the Program For you and not making it yourself , since ur not asking for Info u gave a Program Specifiques to be done for u , UNCOOL

    Author Comment

    im asking people to make a program for me? I simply asked for one function (how to detect key strokes). You would think my requirements (or what you call my program specifics) such as having it compatible with win 98 and win xp, and for it to be simple and effective would be given without me even saying it. The only other thing i added was determining the window that received the keystroke (which i could easily do on my own, but thought maybe the function call for getting the keystroke might also return that info (which now I know it does not). And secondly for all I know, what I asked could  be done with a few lines of code (doesn't seem like the case now). I know how to program, except this is a little beyond me, so I will learn from the source. Im sure thats how millions of people learned. So take it how you like.

    esoft, thanks for that link. I still don't know the difference between a journal hook and wh_keyboard hook and why some source codes say you must use a seperate dll while some code gets around that..and what the pros and cons of each would be...but I guess hopefully ill be able to figure it out on my own after going through and learning all the unknown code in that one link you sent. Seems a little more complicated than I first expected, so maybe ill take smaller baby steps. Thanks again.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
    Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now