I have a logon powershell script. As part of the script, it launches an app, then waits 4 seconds to wait for the computer to catch up, then sends some keystrokes.
$deviceID = "123xyz"
invoke-item ("C:\myapp")
...
$myshell = New-Object -com "Wscript.Shell"
start-sleep -s 4
$myshell.AppActivate("myapp");$myshell.sendkeys("1");$myshell.sendkeys("{TAB}");$myshell.sendkeys("$deviceID");$myshell.sendkeys("{ENTER}")
It works great, unless the user clicks anywhere during the logon. If they do, the app never gets the key strokes and the app flashes in the taskbar.
Seems like AppActivate() doesnt seem to really work. Does anyone have any input on this?