首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在多个窗口中打开网站并使用powershell向下滚动

在多个窗口中打开网站并使用powershell向下滚动
EN

Stack Overflow用户
提问于 2020-09-21 14:54:23
回答 1查看 48关注 0票数 1

我想在一个屏幕上打开4个不同窗口的网站,然后将它们向下滚动一点。到目前为止,我使用Powershell打开它们,调整大小,并将它们放在屏幕上,但我不知道如何向下滚动它们。如果能帮上忙,我们将不胜感激。这是我目前所掌握的.

代码语言:javascript
复制
$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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-21 23:03:04

可以使用具有Scroll(x,y)ScrollTo(x,y)ScrollBy(x,y)方法的Document.ParentWindow向下滚动页面。

下面我使用ScrollBy() (为了简单起见,只在其中一个窗口上使用,但对于其他窗口是一样的)

代码语言:javascript
复制
$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()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63987461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档