无法使用 PowerShell 隐藏 Internet Explorer 窗口

卡西夫

我正在尝试使用 PowerShell 隐藏 Internet Explorer 窗口,并尝试了不同的方法,但没有成功。我在https://superuser.com/questions/1079133/run-a-windows-application-without-displaying-its-gui找到了这段代码,这只适用于记事本。我需要帮助才能使此代码适用于 IE,即打开一个带有 Google 页面的 Internet Explorer 窗口。我想使用下面的代码隐藏这个窗口。

$definition = @"    
      [DllImport("user32.dll")]
      static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

      [DllImport("user32.dll")]
      [return: MarshalAs(UnmanagedType.Bool)]
      static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

      public static void Show(string wClass, string wName)
      {
         IntPtr hwnd = FindWindow(wClass, wName);
         if ((int)hwnd > 0)
            ShowWindow(hwnd, 1);
      }

      public static void Hide(string wClass, string wName)
      {
         IntPtr hwnd = FindWindow(wClass, wName);
         if ((int)hwnd > 0)
            ShowWindow(hwnd, 0);
      }
"@

add-type -MemberDefinition $definition -Namespace my -Name WinApi

[my.WinApi]::Hide('Internet Explorer', 'Google - Internet Explorer')

此代码无法隐藏 Internet Explorer 窗口。

卡西夫

我发现当用“IEFrame”替换“Internet Explorer”时它可以工作。

它适用于以下行

[my.WinApi]::Hide("IEFrame", 'Google - Internet Explorer')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

启动隐藏的Internet Explorer

使用Visual Basic打开Internet Explorer并调整ie窗口的大小

使用VBA从Internet Explorer窗口自动保存PDF文件

使用Powershell浏览网站而无需使用Internet Explorer

Powershell 和 Internet Explorer 标签

Powershell 启用 Internet Explorer 下载

使用Powershell更改受信任域的Internet Explorer安全设置

在带有Adobe Reader的Internet Explorer下,带有弹出窗口和iFrame的GWT / GXT应用程序不会隐藏

Internet Explorer中的隐藏文本

Internet Explorer中的“安全警告”窗口

获取Internet Explorer弹出窗口的URL

启动Internet Explorer时发生意外错误。无法从窗口句柄获取文档(NoSuchDriver)

使用angularjs在Internet Explorer> 11中隐藏禁用的选择选项

Internet Explorer无法显示元素

Javascript Prompt()文本在Internet Explorer 11中部分隐藏

在Internet Explorer中显示/隐藏选择optgroup选项

Internet Explorer 11 中的滚动条隐藏元素

formvalidation.io 隐藏字段 Internet Explorer 错误

如何使用PowerShell在Internet Explorer中抓取模态对话框

使用PowerShell以编程方式将Internet Explorer代理设置配置为在打开之前可以工作

为什么Internet Explorer会阻止弹出窗口?

在Internet Explorer的新窗口中运行javascript代码

在新的Internet Explorer子窗口上设置缩放级别

如何获得在.NET Internet Explorer的窗口句柄参考

如何在Internet Explorer弹出窗口上按保存?

打开计算机时出现的Internet Explorer窗口

使用Selenium的Internet Explorer驱动程序在访问外部网页时不允许处理窗口

calc()无法在Internet Explorer / Microsoft Edge中使用转换

React JS无法与Internet Explorer 9一起使用