Im trying to create a script that refresh edge:
start microsoft-edge:https://login.salesforce.com/?locale=eu
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Microsoft Edge')
while ($true)
{
Sleep 15
$wshell.SendKeys('{f5}')
}
Problem for this that it sends F5 to which windows im at for example if im in notepad it will press f5 it will create timestamp, i want it to send only to edge, is there any way around it?
The following code snippet could do the job. You need to tell which window should be activated, e.g. a s follows:
$medge = Start-Process -PassThru -FilePath microsoft-edge:https://login.salesforce.com/?locale=eu
$wshell = New-Object -ComObject wscript.shell
Start-Sleep -Seconds 15 ### increase time for slow connection
while ( $wshell.AppActivate($medge.Id) ) ### activate the desired window
{
$wshell.SendKeys('{f5}') ### send keys only if successfully activated
Start-Sleep -Seconds 15
}
Above code snippet (derived from the one in question) refreshes microsoft-edge every 15 seconds.
Timing is important:
Start-Sleep
before AppActivate
), and