private bool TextServicesKeystroke(TextServicesContext context, KeyEventArgs keyArgs, bool test)
{
TextServicesContext.KeyOp keyop;
int wParam;
int lParam;
int scancode;
// Cicero's Keystroke Manager and TIP does not recognize VK_RSHIFT or VK_LSHIFT.
// We need to pass VK_SHIFT and the proper scancode.
//
switch (keyArgs.RealKey)
{
case Key.RightShift:
wParam = NativeMethods.VK_SHIFT;
scancode = 0x36;
break;
case Key.LeftShift:
wParam = NativeMethods.VK_SHIFT;
scancode = 0x2A;
break;
default:
wParam = KeyInterop.VirtualKeyFromKey(keyArgs.RealKey);
scancode = 0;
break;
}
lParam = (int)(((uint)scancode << 16) | 1);
if (keyArgs.RoutedEvent == Keyboard.PreviewKeyDownEvent /*keyArgs.IsDown*/)
{
keyop = test ? TextServicesContext.KeyOp.TestDown : TextServicesContext.KeyOp.Down;
}
else
{
// Previous key state and transition state always 1 for WM_KEYUP.
lParam |= (1 << 31) | (1 << 30);
keyop = test ? TextServicesContext.KeyOp.TestUp : TextServicesContext.KeyOp.Up;
}
return(context.Keystroke(wParam, lParam, keyop));
}