Switching keyboards

Giganews Newsgroups
Subject: Switching keyboards
Posted by:  Paul (paul.blommaer…@telenet.be)
Date: Fri, 15 Sep 2006

Hi,
I'm having problems sending keypresses to a remote computer when the
keyboard layout is not the same.
I need to convert kepresses from a French keyboard to a US keyboard and
back.

I used loading both keyboard layaouts and switching to the requested layout
and with MapVirtualKeyEx, but both fail to work correctly.
All normal keys are correct, 'a' on a French keyboard shows correctly on a
US keyboard.
All other keys are wrong : '1' pressed on a US-kbd shows as '&' on the
remote keyboard.

I've testing with this routine with all possible options I can think of
without success.
What am I doing wrong here ?

TIA

Paul

// hklRet:= ActivateKeyboardLayout(HKLremote, 0); //KLF_REORDER);

  if ssCtrl in Shift then
      keybd_event(VK_CONTROL, MapVirtualKeyEx(VK_CONTROL, 0, HKLremote), 0,
0);
  if ssShift in Shift then
      keybd_event(VK_SHIFT, MapVirtualKeyEx(VK_SHIFT, 0, HKLremote), 0, 0);
  if ssAlt in Shift then
      keybd_event(VK_MENU, MapVirtualKeyEx(VK_MENU, 0, HKLremote), 0, 0);

  if Extended then Flag:= KEYEVENTF_EXTENDEDKEY else Flag:= 0;
  keybd_event(vkkey, MapVirtualKeyEx(vkKey, 0, HKLremote), Flag, 0);
  keybd_event(vkKey, MapVirtualKeyEx(vkKey, 0, HKLremote), Flag or
KEYEVENTF_KEYUP, 0);

  if ssAlt in Shift then
      keybd_event(VK_MENU, MapVirtualKeyEx(VK_MENU, 0, HKLremote),
KEYEVENTF_KEYUP, 0);
  if ssShift in Shift then
      keybd_event(VK_SHIFT, MapVirtualKeyEx(VK_SHIFT, 0, HKLremote),
KEYEVENTF_KEYUP, 0);
  if ssCtrl in Shift then
      keybd_event(VK_CONTROL, MapVirtualKeyEx(VK_CONTROL, 0, HKLremote),
KEYEVENTF_KEYUP, 0);

// hklRet:= ActivateKeyboardLayout(HKLlocal, 0); //KLF_REORDER);

Replies