capturing keys when window doesnt have focus

This is a discussion on capturing keys when window doesnt have focus within the Windows Programming forums, part of the Platform Specific Boards category; I would like to set up some hot keys so my window responds to Ctrl+'somecharacter' when it does not have ...

  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,662
    >> 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
    1,608
    You could also use GetAsyncKeyState and GetKeyState.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

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, 07: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, 10: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21