Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 使用HWND选择IE窗口_Powershell_Internet Explorer_Com_Hwnd - Fatal编程技术网

Powershell 使用HWND选择IE窗口

Powershell 使用HWND选择IE窗口,powershell,internet-explorer,com,hwnd,Powershell,Internet Explorer,Com,Hwnd,想知道是否可以基于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} $childW

想知道是否可以基于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

您可以通过搜索
Shell.Application
中的
Windows()
来获取IE对象

$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")

你说的“合作”是什么意思?您想关注新窗口,还是想使用
InternetExplorer.Application
comobject来控制它?我想使用
InternetExplorer.Application
comobject来控制新窗口谢谢,很遗憾,我的代码无法按预期工作。将我的代码添加到原始帖子。您是否尝试使用
LocationName
(网站标题)或
LocationURL
(如果您知道url中您想要的唯一部分)?然后您可以一起跳过hwnd search+。查看更新的答案您是否尝试过
$shell.windows()
?这个您可以找到要搜索的内容。如果它丢失了,那么你的运气就不好了。是的,所以当我只使用
$shell.windows()
时,控制台不会返回任何东西。但是,当我询问
计数时,它返回
1
。古怪的