【发布时间】:2016-08-27 10:59:48
【问题描述】:
想知道是否可以根据 HWND 属性(或类似属性)选择 IE 窗口。我的脚本单击了一个链接,该链接在单独的窗口中打开了一个新页面,我希望能够使用这个新窗口。
这是我的代码:
$ie.Navigate("https://chaseloanmanager.chase.com/Chaselock/ViewOnlineGuide.aspx") # opens page in new window
while ($ie.Busy -eq $true){Start-Sleep -Seconds 2}
$childWindow = Get-Process | Where-Object {($_.ProcessName -eq 'iexplore')} | Get-ChildWindow | Where-Object {$_.ChildTitle -match 'Lending'}
$childWindow.MainWindowHandle # gets HWND of new window
$shell = New-Object -ComObject Shell.Application
$ie3 = $shell.Windows() | Where-Object {$_.HWND -match $childWindow.MainWindowHandle} # does not find window
【问题讨论】:
-
你所说的“合作”是什么意思?你是要关注新窗口还是要使用
InternetExplorer.Applicationcomobjects 来控制它? -
我想用
InternetExplorer.Applicationcom对象来控制新窗口
标签: powershell internet-explorer com hwnd