If I\'m understanding this correctly this code should capture the active window and keep it in focus. concentr.exe is the process name. How do I bring a window in focus base
Have you thought of using the Window Name? I've found this bit of code to work great and not take up a lot of space:
$wshell = New-Object -ComObject wscript.shell
$wshell.AppActivate('New Tab - Google Chrome')
Also, if you need to just Alt-TAB back to the last thing that ran (ie: you need focus to come back to the script window after firing something off) try this:
$wshell = New-Object -ComObject wscript.shell
$wshell.SendKeys('%{TAB}')