title: ToUnicodeEx function fails with any keyboard layout different than mine
body: <p>I'm using <code>ToUnicodeEx</code> function to translate the virtual key code of a pressed key to its unicode character,</p>
  
  <p>This is the function definition:</p>
  
  <pre><code>&lt;DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True, CallingConvention:=CallingConvention.Winapi)&gt;
  Friend Shared Function ToUnicodeEx(
                         ByVal wVirtKey As UInteger,
                         ByVal wScanCode As UInteger,
                         ByVal lpKeyState As Byte(),
                         &lt;Out, MarshalAs(UnmanagedType.LPWStr)&gt;
                         ByVal pwszBuff As StringBuilder,
                         ByVal cchBuff As Integer,
                         ByVal wFlags As UInteger,
                         ByVal dwhkl As IntPtr
  ) As Integer
  End Function
  </code></pre>
  
  <p>The function works perfect for my culture <strong>es-ES</strong> with my keyboard layout <strong>3082</strong>, however, if instead specifying <strong>3082</strong> I try the code below specifying a <strong>1033</strong> keyboard layout to simulate a key pres for <strong>en-US</strong> culture, or whatever any other keyboard layout different than <strong>3082</strong>, then <code>ToUnicodeEx</code> function will fail and returns 0, where a return value of 0 means this:</p>
  
  <blockquote>
    <p>The specified virtual key has no translation for the current state of
    the keyboard.  Nothing was written to the buffer specified by
    pwszBuff.</p>
  </blockquote>
  
  <pre><code>Dim buf As New StringBuilder(256)
  Dim keyboardState As Byte() = New Byte(255) {}
  
  If shift Then
      keyboardState(CInt(Keys.ShiftKey)) = &amp;HFF
  End If
  
  If altGr Then
      keyboardState(CInt(Keys.ControlKey)) = &amp;HFF
      keyboardState(CInt(Keys.Menu)) = &amp;HFF
  End If
  
  InputDevice.NativeMethods.ToUnicodeEx(CUInt(Keys.A), 0UI, keyboardState,  buf,  256,  0UI, 
                                        New IntPtr(1033))
  </code></pre>
  
  <p>What I'm doing wrong?, How I can fix it?</p>