Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


monitoring key events

Posted on 1999-09-27
Medium Priority
Last Modified: 2010-04-01
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 ?
Question by:ioana_marian
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 22

Accepted Solution

nietod earned 100 total points
ID: 2077771
You probably can just use the WaitMessage() function.  If that does not work well, if you program behaves poorly, let me know.

Author Comment

ID: 2080264
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.
LVL 22

Expert Comment

ID: 2080796
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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question