Archived

This topic is now archived and is closed to further replies.

Russell

Getting keystrokes

Recommended Posts

Perhaps this is way out there, but when I do keystrokes I''ve been doing:

  
while(true)
{
if (kbhit())
{
choice = getch(); //get keypress


}
}
[/source[

Might be totally irrelevant, I dunno :)

Share this post


Link to post
Share on other sites
quote:
Original post by Peon
Perhaps this is way out there, but when I do keystrokes I''ve been doing:

That''s essentially DOS/Console-style input while Russell is concerned about Windows input.

Russell: Look into Spy++. I believe there''s some source or further information for it which would give you some good ideas.



I wanna work for Microsoft!

Share this post


Link to post
Share on other sites
To be able to get all keystrokes globally you''d have to write your own keyboard hook.

Try searching the MSDN for some samples of doing it.

It''s not hard at all, just watch out for return values and default functions.

There are other ways as well, but this is the easiest way to do it.

btw, if you DO use hooks, you will have to send out your DLL that hooks the keyboard to the end user as well. So keep that in mind.

Hope this helps...

Share this post


Link to post
Share on other sites
Russell, take a look at this post:

http://www.gamedev.net/community/forums/topic.asp?topic_id=65987

I have already offered my code to Crazemanx, but he never got back to me. You are more than welcome to take a look at it, and use it for whatever you like. It's a basic global scanhook. Just let me know and I'll post a download link for it.

P.S. And if you're not big on translating the code from Delphi to C/C++ the compiled DLL should still work fine.

Edited by - Xorcist on November 7, 2001 2:40:12 PM

Share this post


Link to post
Share on other sites