With a GUI that is somewhat similar to the Run dialog design, using an Edit control and a ListBox control, is there a way to capture all user keystrokes while the ListBox is focused, and re-route those back the Edit control (along with re-focusing the Edit control) if the user starts typing?
For navigation keystrokes (up/down arrows for example), it's easy enough to use (or dynamically enable) hotkeys that check which control is active, and take appropriate action (say the top or bottom of the ListBox is focused and I want the next up/down navigation to re-focus the cursor elsewhere--easy to do using Up:: or Down:: with appropriate #If directives)
For alphanumeric keys, is there a way to capture all keystrokes without having hotkeys for all of them? In other words, I would prefer not to have to do something like:
If I use OnMessage() and WM_KEYDOWN() keyboard handler, I can detect if the user is typing something alphanumeric, but I don't have the exact keystroke pressed... i.e., it can't be detected properly and appended to the current Edit control contents. In most cases wParam can be compared to correctly determine if a letter has been typed, but using chr(wParam) does not always reduplicate the correct character typed (because it misses other things like modifiers and extended keys). It is possible to use wParam comparison to detect an alphanumeric has been typed, and refocus to the Edit control, but then the first keystroke gets missed until the user types further in the Edit control. Also, A_PriorKey will not be updated at the time WM_KEYDOWN() executes.
Code: Select all
a:: b:: ... z:: A:: B:: ... Z:: [every typable character]:: doSomething() Return
Anyone have any clever tricks to capture all keystrokes on the GUI? Or potentially all keystrokes to a particular control (in this case the ListBox). Is it possible to get close to duplicating the keystroke behavior in the Windows run box, which is very similar to this application?