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,
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()
You could create a separate thread, but why not just wait for a WM_CHAR event?
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.
Originally Posted by scwizzo
However, using the GetKeyboardState, the mouse will also be used in this (left, middle, right buttons and the mouse 4 and 5 buttons. )