Thread: capturing keys when window doesnt have focus

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    416

    responding when window is not focused

    I would like to set up some hot keys so my window responds to Ctrl+'somecharacter' when it does not have focus. I used RegisterHotKey(), but it does not help much when the window needs focus for that function to work. Is there a way to make the program respond to certain keystrokes, kind of like a desktop wide hotkey?

    The reason for this is my program is a modeless dialog, and does not display a window on the bottom of the page near the 'Start' button. So to find it you need to close all the other windows. I would like to set up a key system so it is set to the foreground with just a couple keystrokes.
    Last edited by scwizzo; 09-23-2007 at 02:05 PM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> I used RegisterHotKey(), but it does not help much when the window needs focus for that function to work.
    RegisterHotKey() is system wide. Your app does not need focus.

    http://msdn2.microsoft.com/en-us/library/ms646309.aspx

    gg

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Quote Originally Posted by Codeplug View Post
    >> I used RegisterHotKey(), but it does not help much when the window needs focus for that function to work.
    RegisterHotKey() is system wide. Your app does not need focus.

    http://msdn2.microsoft.com/en-us/library/ms646309.aspx

    gg
    ... wow i feel dumb. It didn't work with ctrl+shift, but I think i had the switch statement screwed up inside the identifier message. Thank you.

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    You could also use GetAsyncKeyState and GetKeyState.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM