I am writing a powershell script that goes through 3 chrome windows (not tabs, these windows are on 3 different monitors) and want to refresh every window. I cannot figure out a way to switch between windows.
I have the following code:
while(1) { # Loop forever
sleep -Seconds 15 # Wait 15sec
$wshell = New-Object -ComObject wscript.shell
if($wshell.AppActivate('Chrome')) { # Switch to Chrome
Sleep 1 # Wait for Chrome to "activate"
$wshell.SendKeys('{F5}') # Send F5 (Refresh)
} else { break; } # Chrome not open, exit the loop
}
This only refreshes one page. I tried to use
[System.Windows.Forms.SendKeys]::SendWait("%+{ESC}")
to switch between apps, but since there are other open apps it is not possible.
Is there a way to switch between Chrome windows? Haven't found any shortcuts or solutions.
Thank you!