title: Powershell simulate Keyboard
body: <p>I have a problem using sendkeys is Powershell. I'm trying to make a script that wil send the keys: shift,w,a,s,d to a game. The code i'm trying is:</p>
  
  <pre><code>Add-Type -AssemblyName System.Windows.Forms
  [System.Windows.Forms.SendKeys]::SendWait(+{w}{a}{s}{d});
  </code></pre>
  
  <p>But when I use this it just sends "Wasd". It won't change the movement, i can see that this has been send in the in-game console.</p>
  
  <p>Is there a way i can simulate the keypresses?</p>
  
  <p>It can by done for the left mouse button using this:</p>
  
  <pre><code>    $signature=@' 
            [DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
            public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
      '@ 
  
      $SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
  
  $SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
  $SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
  </code></pre>
  
  <p>Is there something similar for the keyboard?</p>