1

I want to open 4 websites in different windows on one screen and then scroll them down a little. So far I used Powershell to open, size and place them on the screen but I can't figure out how to scroll them down. Help would be appreciated. Here's what I have so far...

$ie1 = new-object -comobject InternetExplorer.Application
$ie1.navigate("http://www.xe.com/ja/currencycharts/?from=USD&to=JPY&view=12h")
$ie1.visible = $true    
$ie1.top = 0
$ie1.width = 800
$ie1.height = 500
$ie1.Left = 0

$ie2 = new-object -comobject InternetExplorer.Application
$ie2.navigate("http://www.xe.com/ja/currencycharts/?from=CNY&to=JPY&view=12h")
$ie2.visible = $true    
$ie2.top = 0
$ie2.width = 800
$ie2.height = 500
$ie2.Left = $ie1.left + $ie2.width

$ie3 = new-object -comobject InternetExplorer.Application
$ie3.navigate("http://www.xe.com/ja/currencycharts/?from=THB&to=JPY&view=12h")
$ie3.visible = $true    
$ie3.top = 500
$ie3.width = 800
$ie3.height = 500
$ie3.Left = 0 

$ie4 = new-object -comobject InternetExplorer.Application
$ie4.navigate("http://www.xe.com/ja/currencycharts/?from=USD&to=MXN&view=12h")
$ie4.visible = $true    
$ie4.top = 500
$ie4.width = 800
$ie4.height = 500
$ie4.left = $ie3.left + $ie4.width

 
Phil
  • 13
  • 2
  • Does it have to be Powershell? Do you need to have the 4 browser windows for something? Perhaps one browser showing the 4 web pages in 4 iframes (https://www.w3schools.com/html/html_iframe.asp) would be more concise for the screen real estate. Then you could also scroll each of the pages using this hint: https://stackoverflow.com/questions/1192228/scrolling-an-iframe-with-javascript – Jan Dolejsi Sep 21 '20 at 07:57
  • try to use selenium api module for PowerShell https://github.com/adamdriscoll/selenium-powershell – LosFla Sep 21 '20 at 17:45

1 Answers1

0

It is possible to have the pages scroll down using the Document.ParentWindow which has methods Scroll(x,y), ScrollTo(x,y) and ScrollBy(x,y).

Below I'm using ScrollBy() (for brevity only on one of the windows, but for the others it is the same thing)

$scrollDownValue = 300  # just a wild guess, must be an integer value

$ie1 = New-Object -ComObject InternetExplorer.Application
$ie1.Visible = $true    
$ie1.Top     = 0
$ie1.Width   = 800
$ie1.Height  = 500
$ie1.Left    = 0
$ie1.Navigate("http://www.xe.com/ja/currencycharts/?from=USD&to=JPY&view=12h")
# wait for it..
while ($ie1.Busy -and $ie1.ReadyState -ne 4) { Start-Sleep -Seconds 1 }

$ie1.Document.ParentWindow.ScrollBy(0, $scrollDownValue)

# important: release the COM object(s) when done
$null = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie1)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
Theo
  • 57,719
  • 8
  • 24
  • 41