I am trying to write a script and need to mimic some keystrokes after a new dialogue box pops up. When I get to this function block, powershell returns "False" and does not do the 'keystrokes.' I feel like I'm not making it to the next window.
function ats{
$wshell = New-Object -ComObject wscript.shell;
cmd /c C:\location\location\ats.exe
$wshell.AppActivate('Administrative Tool Suite (ATS)')
Sleep 1
$wshell.SendKeys('TAB')
sleep .5
$wshell.SendKeys('TAB')
sleep .5
$wshell.SendKeys('TAB')
sleep .5
$wshell.SendKeys('TAB')
sleep .5
$wshell.SendKeys('~')
}
ats