[英]open websites in multiple windows and scroll them down using powershell
我想在一个屏幕上打开 4 个不同的 windows 网站,然后将它们向下滚动一点。 到目前为止,我使用 Powershell 打开、调整大小并将它们放置在屏幕上,但我不知道如何向下滚动它们。 帮助将不胜感激。 这是我到目前为止所拥有的...
$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
可以使用具有方法Scroll(x,y)
、 ScrollTo(x,y)
和ScrollBy(x,y)
的 Document.ParentWindow 使页面向下滚动。
下面我使用的是 ScrollBy() (为简洁起见,仅在 windows 之一上,但对于其他人来说是一样的)
$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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.