Hotkeys!

This is a discussion on Hotkeys! within the Windows Programming forums, part of the Platform Specific Boards category; Hey, I'm going to make a MFC application that will use hotkeys. I understand the RegisterHotkey() function, I am just ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155

    Hotkeys!

    Hey,

    I'm going to make a MFC application that will use hotkeys.

    I understand the RegisterHotkey() function, I am just a little confused on the Binding process.


    I've got an edit box (readonly) right next to a button that says "Set Key Binding". When the user presses that button, it will change the edit box to say "Press a Key" and the button will say "Cancel Key Binding". The user than can enter any one of the 255 VKeys (including left mouse) however, if the user presses left mouse on the button that cancels the binding, it won't register it.

    I've currently got a very crude version working. Basically, when the user presses the button, a for loop starts (goes from 1-255) checking for GetAsyncKeyState ( i ). This goes on until a key is pressed.

    The limitations of my version:
    • Freeze the MFC window until a key is pressed
    • Doesn't allow for changing of the text on the button or the edit box
    • Makes my antivirus think my program is a keylogger =D
    • Uses all of my CPU
    • Allows for only ONE keypress (no ALT+F5 stuff, just ALT or F5)


    I'm hoping there's another way (similar to the way Xfire does it).

    Thanks in advance,

    Guitarist809
    ~guitarist809~

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    I don't understand about the left mouse click not registering. Do you mean you want to register the left mouse click, but when you use the mouse to actually click the button it wont register it? Try having the button gain focus and use the enter key to hit the button then see if the mouse button gets registered.

    For multiple keys, try using GetKeyboardState()

  3. #3
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    You could create a separate thread, but why not just wait for a WM_CHAR event?

  4. #4
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155
    Quote Originally Posted by scwizzo View Post
    I don't understand about the left mouse click not registering. Do you mean you want to register the left mouse click, but when you use the mouse to actually click the button it wont register it? Try having the button gain focus and use the enter key to hit the button then see if the mouse button gets registered.

    For multiple keys, try using GetKeyboardState()
    Uh... I meant the left mouse will be detected, unless the user clicks the "cancel key bind" button. If the user clicks that, it will not bind the left mouse and instead use the previous vkey submitted.

    However, using the GetKeyboardState, the mouse will also be used in this (left, middle, right buttons and the mouse 4 and 5 buttons. )
    ~guitarist809~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enumerating timers and hotkeys
    By maxorator in forum Windows Programming
    Replies: 3
    Last Post: 01-01-2007, 10:47 AM
  2. Hotkeys with [Fn]
    By Hunter2 in forum Windows Programming
    Replies: 1
    Last Post: 04-04-2005, 10:27 PM
  3. remapping hotkeys and Winamp
    By confuted in forum Tech Board
    Replies: 0
    Last Post: 08-30-2003, 03:54 PM
  4. BCB and Hotkeys
    By Zeedo in forum C++ Programming
    Replies: 3
    Last Post: 12-14-2002, 02:44 PM
  5. Hotkeys
    By Zeedo in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 01:04 PM

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