// JP opened flex table

Click to See Complete Forum and Search --> : Keyboard redirection


omri
December 31st, 2002, 04:11 AM
Hi
I have a program that redirects keyboard inputs by using low level keyboard procedure hook.
This hook is installed by calling SetWindowsHookEx(WH_KEYBOARD_LL,,,).
The procedure calls PostMessage to send keyboard KEYDOWN and KEYUP inputs to a window.
The problem is that when running the program on Windows Embedded NT sp6 operating system,
the receiving application cannot translate the keystrokes when SHIFT is down.
For example, when redirecting the sequence SHIFT DOWN, '6' DOWN, '6' UP, SHIFT UP,
The receiving application should translate this to WM_CHAR '^'. Instead, we get WM_CHAR '6'.
In Windows 2000, this works fine in most cases.
Note: could be that the operating system is not an issue. This was not deeply checked.

The following code samples the procedure's operation:

union lParamData_
{
struct
{
unsigned short repeat_count;

unsigned char scan_code;

unsigned char extended :1;
unsigned char reserved :4;
unsigned char context_code :1;
unsigned char prev_state :1;
unsigned char trs_state :1;
}bit;

DWORD val;
};


RESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
union lParamData_ lParamData;
if ( nCode == HC_ACTION )
{
switch (wParam)
{
case WM_KEYDOWN:
memset(&lParamData,0,sizeof(lParamData));
lParamData.bit.repeat_count = 1;
lParamData.bit.scan_code = (unsigned char)p->scanCode;
PostMessage(MyWindowHandle, WM_KEYDOWN, p->vkCode, lParamData.val);
break;

case WM_KEYUP:
memset(&lParamData,0,sizeof(lParamData));
lParamData.bit.repeat_count = 1;
lParamData.bit.prev_state = 1;
lParamData.bit.trs_state = 1;
lParamData.bit.scan_code = (unsigned char)p->scanCode;
PostMessage(MyWindowHandle, WM_KEYUP, p->vkCode, lParamData.val);
break;

default:

break;
}
}
return CallNextHookEx(g_hTheHookProc, nCode, wParam, lParam);
}


Any Ideas?
Is there a better way of doing that?

Thanks
Omri

//JP added flex table