Keyboard Hook (C++)

This is a discussion on Keyboard Hook (C++) within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I have been into Win32 API programming for a quite a few months now and have gotten curious about ...

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    Keyboard Hook (C++)

    Hello, I have been into Win32 API programming for a quite a few months now and have gotten curious about hooks. I wrote a simple program that sets hooks on the keyboard but it is local only. I want to set global hooks. No this is not for malicious purposes either. I heard that I need to write a dll file to make the hooks global? I can't use the WH_KEYBOARD_LL either because I am running Win98. I can't seem to find any good info on writing a dll for keyboard hooks. Anyone know about this? Thanks.

    EDIT: Oh I forgot, I am using Dev-C++.

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    Am I correct in thinking that hooks basically "take" the devices message and pass them to your window? Or am I wrong? lol
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Yes, hooks will, in a sense, copy the message and route it to your program. The program it is intended for still gets it but your program gets it as well.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    Ooooooooo that's awesome.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,264
    I posted an example on how to do this here

  6. #6
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Ok thanks, I checked it out and it was a good article.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  7. #7
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    I tried a couple times to make that sample program work, so I could break it down later, and it compiles and everything but when I run it the Unable to install hooks comes up and then the Unable to unload hooks comes up. I named the .dll keyhook.dll since that's the name of the file you are loading, but it still won't load the hooks? Does the main .cpp file need to have a certain name that the .dll file is looking for? Sorry if this is a newb question, I have never used hooks before.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simulate Keys with a Keyboard Hook
    By guitarist809 in forum Windows Programming
    Replies: 3
    Last Post: 11-14-2008, 08:14 PM
  2. C++ Global Keyboard Hook
    By darknite135 in forum C++ Programming
    Replies: 4
    Last Post: 02-01-2008, 07:36 PM
  3. Keyboard hook
    By joecaveman in forum Windows Programming
    Replies: 2
    Last Post: 09-03-2005, 09:07 AM
  4. Keyboard Hook
    By jmd15 in forum Windows Programming
    Replies: 19
    Last Post: 08-07-2005, 04:11 PM
  5. How to keep static data in a keyboard hook?
    By junbin in forum Windows Programming
    Replies: 1
    Last Post: 01-19-2003, 03:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21