Select IE window 使用 HWND
Select IE window using HWND
想知道是否可以 select 一个基于 HWND 属性(或类似的)的 IE window。我的脚本单击 link,它会在单独的 window 中打开一个新页面,我希望能够使用这个新的 window。
这是我的代码:
$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
您可以在 Shell.Application
中搜索 Windows()
来获取 IE comobject。
$shell = New-Object -ComObject Shell.Application
$ie = $shell.Windows() | Where-Object { $_.LocationURL -match 'Lending' }
#$ie = $shell.Windows() | Where-Object { $_.HWND -eq 2951084 }
$ie.Navigate("http://www.whosebug.com")
想知道是否可以 select 一个基于 HWND 属性(或类似的)的 IE window。我的脚本单击 link,它会在单独的 window 中打开一个新页面,我希望能够使用这个新的 window。
这是我的代码:
$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
您可以在 Shell.Application
中搜索 Windows()
来获取 IE comobject。
$shell = New-Object -ComObject Shell.Application
$ie = $shell.Windows() | Where-Object { $_.LocationURL -match 'Lending' }
#$ie = $shell.Windows() | Where-Object { $_.HWND -eq 2951084 }
$ie.Navigate("http://www.whosebug.com")