Shift States, Alt States, etc. (OpenInsight Specific)
At 23 SEP 1998 06:14:38PM Greg James, ISIS, Inc. wrote:
When using SEND_MESSAGE with QUALIFY_EVENT, how can you determine the 'state' of the shift and/or alt keys? In order to identify 'Alt-J' would it be necessary to write a script that first looks for character 17 and then for character 74?
At 24 SEP 1998 07:08AM Oystein Reigem wrote:
Greg,
I'm in the middle of experimenting with button messages, but since there's a fair chance I need to handle key messages as well, I tried some of that now. I'm not an expert on this stuff exactly, but I learn as I move along.
Do you use the WM_KEYDOWN (hex 0100=int 256) and/or WM_KEYUP (hex 0101=int 257) messages? Then it seems you're right about your assumption. You get the messages for the Shift and Ctrl keys separately from the character keys, and it seems you must keep track of the state of the Shift and Ctrl keys yourself. The lParam contains a "virtual key code", which is 16 (VK_SHIFT) for the Shift key and 17 for the Ctrl key (VK_CONTROL). You have to use both WM_KEYDOWN and WM_KEYUP of course.
NB! In your posting you talk about the Alt-J key combination. But there is no virtual key code for the Alt key! I think the Alt key combinations are handled in a completely different way.
But assuming it's Shift and Ctrl key combinations you want to handle I found another message that seems better than WM_KEYDOWN and WM_KEYUP. It seems the message WM_CHAR (hex 0102=int 258) has an lParam that contains the ASCII value. So the "J" key alone generates a WM_CHAR message with lParam=106 (lowercase j), Shift-J produces 74 (uppercase J), and Ctrl-J produces 10.
- Oystein -
PS. I find some of the stuff I need not in Microsoft docs but in files that belong to Delphi.
At 24 SEP 1998 10:33PM Cameron Revelation wrote:
Greg,
If you want to do something on ALT-J, put the action on a menu item and set the accellerator to ALT-J. Optionally, you can set the menu item to invisible in the menu designer.
Cameron Purdy
Revelation Software
At 25 SEP 1998 10:43AM Greg James, ISIS, Inc. wrote:
Cameron,
I shouldn't have been so specific in my original posting. I realize that the same thing can be accomplished using a hidden menu item that uses an Alt-J shortcut. I guess my real question is how can you intercept combinations of keystrokes, using send_message with qualify_event? I am particularly interested in intercepting a Shift-Tab. When I try to do this I get two different wparams: 16 and 09, respectively. Any suggestions?
Thanks
At 25 SEP 1998 08:36PM Cameron Revelation wrote:
Greg,
That sounds about right. Windows gives OpenInsight fairly raw data, basically what keys were pressed down (and when they get released) and the OpenInsight turns around and asks Windows to "translate" and dispatch those messages. Sometimes during translation, and sometimes in its "default processing" for window messages, Windows does things like:
- produce "higher level" events like WM_CHAR (which is more like what you are thinking of)
- do clicks (space, enter), fire accelerators, etc.
If you must try to catch any keystroke, you can try some of the following:
#define WM_KEYDOWN 0x0100
#define WM_KEYUP 0x0101
#define WM_CHAR 0x0102
#define WM_DEADCHAR 0x0103
#define WM_SYSKEYDOWN 0x0104
#define WM_SYSKEYUP 0x0105
#define WM_SYSCHAR 0x0106
#define WM_SYSDEADCHAR 0x0107
Note that the current "focus" gets the key-related messages … that is actually the definition of "focus" in Windows.
Cameron Purdy
Revelation Software