使用HWND选择IE窗口 [英] Select IE window using HWND

查看:200
本文介绍了使用HWND选择IE窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否可以根据HWND属性(或类似)选择IE窗口。我的脚本单击一个链接,在单独的窗口中打开一个新页面,我希望能够使用这个新窗口。

Wondering if it is possible to select an IE window based on the HWND property (or similar). My script clicks a link which opens a new page in a separate window and I would like to be able to work with this new 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 >。

You can get the IE comobject by searching through Windows() in Shell.Application.

$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.stackoverflow.com")

这篇关于使用HWND选择IE窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆