RegisterHotKey

Aug 4, 2010 at 8:56am
Is there a way to register a double press of a key with registerhotkey?

If not, whats the best way to catch a double press?
Im thinking registerhotkey, catch the event, and save what key was pressed at what time, if shortly after the same event is recieved, its should be a double key press

also, is there a way to know when a key has been pressed without using registerhotkey? because registerhotkey seems to disable the key press events for all other programs
Last edited on Aug 4, 2010 at 9:24am
Aug 5, 2010 at 8:43am
also, is there a way to know when a key has been pressed without using registerhotkey?

Yes. When you press a key, WM_CHAR message ( http://msdn.microsoft.com/en-us/library/ms646276(VS.85).aspx ) is sent to your program
Last edited on Aug 5, 2010 at 8:44am
Aug 5, 2010 at 9:03am
Forgot to say, that the application will not have keyboard focus =P

Also, is it possible to know if a numpad key is being pressed without numlock on?
Yesterday i did some testing with RegisterHotKey, and i only got the numpad to work(only recieved WM_HOTKEY messages), when numlock was on

(Im trying to turn the numpad on my laptop into something useful)
Last edited on Aug 5, 2010 at 9:04am
Aug 5, 2010 at 9:43am
Also, is it possible to know if a numpad key is being pressed without numlock on?

You can check if numlock is on yourself:
1
2
3
4
5
6
7
8
9
SHORT state=GetKeyState(VK_NUMLOCK);
if(state==TRUE)
  {
    std::cout <<"Numlock is ON "<<std::endl;
  }
else
  {
    std::cout <<"Numlock is OFF"<<std::endl;
  }


Maybe you want to use keyboard hooks?
http://www.cplusplus.com/forum/windows/26249/


Aug 5, 2010 at 9:59am
Also, is it possible to know if a numpad key is being pressed without numlock on?

You can check if numlock is on yourself:
I know how to check if numlock is on, the problem is that with RegisterHotKey the app would only recieve the hotkey messages if numlock was on, so numlock somehow disabled the numpad completely

And thanks for the keyboard hook idea ill try it out asap when i get home ^^
Last edited on Aug 5, 2010 at 10:00am
Topic archived. No new replies allowed.