1つの画面の異なるウィンドウで4つのWebサイトを開き、それらを少し下にスクロールしたいと思います。これまで、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
ページがメソッドを持ってDocument.ParentWindowを使用して、下にスクロールさせることが可能であるScroll(x,y)
、ScrollTo(x,y)
とScrollBy(x,y)
。
以下では、ScrollBy()を使用しています(簡潔にするために、ウィンドウの1つのみを使用していますが、他のウィンドウも同じです)
$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()
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加