现有IE实例中的“打开"选项卡 [英] Open tab in existing IE instance

查看:80
本文介绍了现有IE实例中的“打开"选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ie = New-Object -com internetexplorer.application

每次我使用此对象打开一个新网站(即每次运行脚本时),都会在新的IE窗口中打开它,而我不希望它这样做.我希望在新选项卡中打开它,但也要在以前打开的IE窗口中打开它.我想在下次运行脚本时重用该对象.我不想创建一个新对象

Everytime i open a new website with this object(ie every time when script runs) it is opened in a new IE window and i don't want it to do that. I want it to be opened in a new tab but that too in a previously opened IE window. I want to reuse this object when the script runs next time. I don't want to create a new object

那么有什么方法可以检查Internet Explorer的实例并重用它的实例?

So is there any way like to check for the instances of internet explorer and to reuse its instance ???

我尝试过此解决方案:

首先,您必须附加到已经运行的Internet Explorer实例:

First you have to attach to the already running Internet Explorer instance:

$ie = (New-Object -COM "Shell.Application").Windows() `
    | ? { $_.Name -eq "Windows Internet Explorer" }

然后,您导航到新URL.通过Flags参数控制打开URL的位置:

Then you Navigate to the new URL. Where that URL is opened is controlled via the Flags parameter:

$ie.Navigate("http://www.google.com/", 2048)

,但是无法在此新创建的对象$ie上调用navigate方法.

but am not able to call navigate method on this newly created object $ie.

推荐答案

您可以使用Start-Process打开URL.如果浏览器窗口已经打开,它将作为选项卡打开.

You can use Start-Process to open the URL. If a browser window is already open, it will open as a tab.

Start-Process 'http://www.microsoft.com'

这篇关于现有IE实例中的“打开"选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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