public static void SendUnicodeKeyboardInput(char key, bool press)
{
//CASRemoval:AutomationPermission.Demand(AutomationPermissionFlag.Input);
UnsafeNativeMethods.INPUT ki = new UnsafeNativeMethods.INPUT();
ki.type = UnsafeNativeMethods.INPUT_KEYBOARD;
ki.union.keyboardInput.wVk = (short)0;
ki.union.keyboardInput.wScan = (short)key;
ki.union.keyboardInput.dwFlags = UnsafeNativeMethods.KEYEVENTF_UNICODE | (press ? 0 : UnsafeNativeMethods.KEYEVENTF_KEYUP);
ki.union.keyboardInput.time = 0;
ki.union.keyboardInput.dwExtraInfo = new IntPtr(0);
if (UnsafeNativeMethods.SendInput(1, ref ki, Marshal.SizeOf(ki)) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}