title: PowerShell script to simulate "Enter" press
body: <p>I have a PowerShell script that runs a program which requires a user to press "Enter" before the script can advance.  Being that I'm trying to automate this process, I want to eliminate user involvement.  Is there a way to simulate this "Enter" press within the PowerShell script?  I have tried:</p>
  
  <pre><code>$wshell = New-Object -ComObject wscript.shell;
  $wshell.AppActivate('title of the application window')
  Sleep 1
  $wshell.SendKeys('~') 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$wshell = New-Object -ComObject wscript.shell;
  $wshell.AppActivate('title of the application window')
  Sleep 1
  Add-Type -AssemblyName System.Windows.Forms
  [System.Windows.Forms.SendKeys]::SendWait('~');
  </code></pre>
  
  <p>but it still requires the user to press "Enter" and then it prints "False".  It then adds a return at the very end of the program regardless of this code placement in the program.</p>