-
Keyhooking?
What im looking for is a way to detect a key press when focus is NOT on my window, i believe this is called keyhooking. Im just looking for a few simple lines i can stick in my program for when somebody presses like X for example it would execute BOB().
If anybody has a good tutorial on keyhooking, providing working VC++6.x code (NOT .NET) or you can just post a few lines of it to do what i want, im very interested in hearing from you. Thanks alot for the time guys, i really appreciate what you do here.
-
Why do you want to do that?
Key logging is a very common illegal activity, and hence discussion/advice is banned on the forums here. I think you should give a legitimate reason for your application.
-
I don't know about DeepBlackMagic, but I use key hooks to provide extra functionality with my keyboard. For example, I override the "shopping" & "webcam" buttons to do things they were never intended for, and also take control over the scrollywheel to the side of the keyboard as I dislike the way the driver handles it.
That's one example of a non-illegal use, although I must say, I can't think of many others!
-
Key hooking can be used as a very destructive tool, but I don't seriously see it as anything evil (if you consider the many other “bad” functions out there). It can be very useful for applications developers, like for ex. checking if the user has been idle or hook some keys as shortcuts, as _Elixia_ said. But be aver, key hooking isn’t as simple as it may appear.
Hopefully you wont use this for any illegal activity, as andrianxw pointed out.
-
If you read my previous posts, you will come to realize that just about all of my questions deal with topics with few if any uses legitimate or otherwise. In this particular case it has to do with key rebinding for an application. Im interested in useing a key that is mostly unused by various environments and replacing it with a combonation of keystrokes that is useful. The idea i had in mind has been described to several people i know and they all expressed interest in its use ranging from video games to office applications. If my window has focus my program works perfectly (i sleep for 3 seconds so they may return focus to the target window manually), all i need is the knolwedge of how to catch keypresses not directed toward my application. I understand that keylogging is illegal, bla bla bla, however if i wanted to do that i would be using one of the hundred applications that already offers such functionality.
-
I'll give you a start... Check out SetWindowsHookEx. If you are dedicated enough, you'll find out the rest on your own.
BTW, if a mod decides this in inappropriate, feel free to edit this.
-
Check my email I sent you a while ago. Also, RegisterHotKey may do what you require - Windows will then do the key processing for you and simply send you a message when a user presses your hotkey, regardless of which application the key was pressed in.
-
keyhooking isnt illegal, well as long as you agreed to the idea that one is being put onto your computer lol like some peer2peer applications i know of, they let u dl the program say kazaa 4 example and at the verry end of the eula it says all sorts of crap like "i agree to allow installation of third party programs such as key loggers and other such spyware" besides keyloggers are useful aswell, as long as being used to stop the bad instead of loging credit card details lol
-
Thanks guys, i found an older tutorial from M$. My laptop now has an autosave button, as well as 3 or 4 other random function keys. Take that you useless surf-the-net key. It doesnt compiler under VC++6.0SP5 but i got it working with nmake from the cmdline. There are a few features i would like to add but they are more windows than hooking. I basically ended up with 2 C files. One DLL that has the callbacks, and one window that allows me to install/deinstall the hooks. Thanks for the help. i think u guys are a little too paranoid around things that could potentially be used for evil. I would be too if i had a bunch of script kiddies posting asking how to make a keylogger.
-
I've emailed you a full example.