我想在一个屏幕上打开4个不同窗口的网站,然后将它们向下滚动一点。到目前为止,我使用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发布于 2020-09-21 23:03:04
可以使用具有Scroll(x,y)、ScrollTo(x,y)和ScrollBy(x,y)方法的Document.ParentWindow向下滚动页面。
下面我使用ScrollBy() (为了简单起见,只在其中一个窗口上使用,但对于其他窗口是一样的)
$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()https://stackoverflow.com/questions/63987461
复制相似问题