Search code examples
powershellwindows-scriptingcomobjectwscript.shell

How to use wscript.shell to ALT+Tab?


Is it possible to use wscript.shell to send an ALT+TAB ?

$wshell = New-Object -ComObject wscript.shell;
$wshell.SendKeys('\t')

Solution

  • I use System.Windows.Forms.SendKeys instead.

    Add-Type -AssemblyName System.Windows.Forms
    [System.Windows.Forms.SendKeys]::SendWait('%{TAB}')
    

    Not sure why but wscript.shell doesnt't work with %{TAB}.