I’ve been working on this script and it works on my PC but I am positive it can be broken if the timing is changed slightly.
The first problem is I can’t figure out how to sendkeys to the program in order to make it start running and simultaneously keep the program from closing via the /w or | out-null commands. When I try to add the out-null lines the script will still close the app before it is done running.
The 2nd issue is that I have inserted pauses in order to navigate the apps via sendkey commands but obviously this is gonna cause a problem if the app run speed varies even slightly.
So yeah… I am sure there are other problems that will arise but these are the two I can see right now. Any advice would be greatly appreciated. Thank you.
& start “C:\program.lnk”
sleep 1
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate(‘C:\program.lnk’)
Sleep 1
$wshell.SendKeys(‘{right}’)
Sleep 1
$wshell.SendKeys(‘~’)
Sleep 1
$wshell.SendKeys(‘{right}’)
Sleep 1
$wshell.SendKeys(‘~’)
sleep 5
get-process program | %{ $.closemainwindow() }
& start “C:\program.lnk”
Sleep 3
$wshell.SendKeys(‘~’)
sleep 5
get-process program | %{ $.closemainwindow() }
$wshell.SendKeys(‘{right}’)
Sleep 3
$wshell.SendKeys(‘~’)
& start “C:\program.lnk”
sleep 3
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate(‘C:\program.lnk’)
sleep 1
$wshell = New-Object -ComObject wscript.shell;
$wshell.SendKeys(‘{tab}’)
sleep 1
$wshell.SendKeys(‘{tab}’)
sleep 1
$wshell.SendKeys(‘{tab}’)
sleep 1
$wshell.SendKeys(‘{tab}’)
sleep 1
$wshell.SendKeys(‘~’)
sleep 1
$wshell.SendKeys(‘~’)
sleep 200
get-process program | %{ $_.closemainwindow() }
sleep 2
& start “C:\program.lnk”
$wshell = New-Object -ComObject wscript.shell;
sleep 10
$wshell.SendKeys(‘~’)
sleep 10
$wshell.SendKeys(‘~’)