From: Charles Calvert Date: 2008-03-30T05:30:08+09:00 Subject: Re: how to get raw keyboard input in windows ? On Sat, 29 Mar 2008 05:07:37 -0700, wbsurfver@yahoo.com wrote: > Here's my current problem: > I would like to be able to read raw keyboard data, so that if I hit > spacebar or some function key, it would pause, even if the dos shell > running the program was not in focus. How can I do that ? You're trying to do something outside of normal Windows functionality. It is possible, but difficult and brittle. Look at the function SetWindowsHookEx here: . If you specify 0 for the thread ID, you can hook all of the applications and monitor their keyboard events. The problem with doing this is that you have to create a DLL with a function that will signal your process via some sort of IPC. When you call SetWindowsHookEx, your DLL will be loaded into the address space of each process you hook. You have to be very careful that your code doesn't do anything nasty, as it will be running in every process with a message pump on the system and could potentially bring the whole thing to its knees. Finally, IME some parts of the hooking API (notably the mouse hooking) don't work as advertised. I don't recall any specific problems with the keyboard, but keep your eyes peeled. -- Charles Calvert | Software Design/Development Celtic Wolf, Inc. | Project Management http://www.celticwolf.com/ | Technical Writing (703) 580-0210 | Research