• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

monitoring key events

I work on an MDI application with VC++5.
I make a mouse recorder. I need to sleep a while,
take a pause or delay for a time. I have found
only Sleep - function. How else I can wait ?
I can't use Sleep , because I need to get
keyboard events ( key down) and if I use Sleep ,
key down is delayed and handled at the end
of demonstration which use Sleep .
How can I monitorize the keyboard during
my demonstration when I use a pause function ?
  • 2
1 Solution
You probably can just use the WaitMessage() function.  If that does not work well, if you program behaves poorly, let me know.
ioana_marianAuthor Commented:
It's not very useful.
I need to make a demonstration with the mouse. Which means that I have
to move the mouse from pos to pos , and sleep - or delay on some positions.
Meanwhile , in this sleep times, I have to take any key down code and
modify demonstration if I have to. I can't use WaitMessage, because
I have to wait a specific time(in ms) . I hope I was explicite.
Then why did you accept the answer?  You didn't like the answer, so you gave me a bad grade, but no you are asking for a good answer.  You should have waited rather than giving me a bad grade.

It sounds to me like you don't want to sleep at all.  If this is for a ordinary windows program, as it sounds like, you need to be processing message at "all" times so you need to be returning to your message loop frequently.  (And the message loop will allow the application to sleep when there are no messages.)  What you should do is to create a timer using SetTimer().  This timer will post a WM_TIMER to your application at regular intervals.  When you get the message, you can update the mouse position.  Other than that, you application should do nothing special  It will sleep when there are no messages.  You will handle key strokes and other events completely as usual.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now