title: SendInput() and non-English characters and keyboard layouts
body: <p>I'm having trouble simulating character keypresses when a non-English input keyboard language is being used in Windows.</p>
  
  <p>I tried calling SendInput() with KEYEVENTF_UNICODE:</p>
  
  <pre><code>KEYBDINPUT ki;
  INPUT input;
  int character = 0;
  
  ki.wVk = 0;
  ki.wScan = character;
  ki.dwFlags = KEYEVENTF_UNICODE;
  ki.time = 0;
  ki.dwExtraInfo = 0;   
  input.type = INPUT_KEYBOARD;
  input.ki = ki;
  SendInput(1, &amp;input, sizeof(INPUT));
  </code></pre>
  
  <p>And this actually works (of course, in my code, I also do a KEYUP after the key down)... except in GTK+ apps (there may be other instances where it doesn't work either).</p>
  
  <p>According to <a href="http://msdn.microsoft.com/en-us/library/ms646271%28VS.85%29.aspx" rel="noreferrer">MSDN</a>, <i>If KEYEVENTF_UNICODE is specified, SendInput sends a WM_KEYDOWN or WM_KEYUP message to the foreground thread's message queue with wParam equal to VK_PACKET. Once GetMessage or PeekMessage obtains this message, passing the message to TranslateMessage posts a WM_CHAR message with the Unicode character originally specified by wScan. This Unicode character will automatically be converted to the appropriate ANSI value if it is posted to an ANSI window.</i></p>
  
  <p>So I believe that when KEYEVENTF_UNICODE is passed, the functionality of SendInput() is different... not as low-level as it usually is.</p>
  
  <p>For the life of me, I can't figure out any other way to get SendInput() to print out characters properly for the user's keyboard language. For example, if the keyboard input language is "Swedish", I can't get it to output '@' (instead, it prints out a quotation mark), and I can't get it to output non-ASCII characters properly, either (accented letters, etc).</p>
  
  <p>Thanks in advance.</p>