在Powershell中聚焦IE窗口 [英] Focus IE window in powershell

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

问题描述

我的代码:

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://localhost")
$ie.visible = $true
$ie.fullscreen = $true

但是,全屏显示后,该窗口仍显示在Windows任务栏的后面.当我单击窗口以使其聚焦时,任务栏将落在后面,并显示我想要的方式.如何以编程方式执行此操作?谢谢!

However, after fullscreen, the window still appears behind the Windows taskbar. When I click the window to give it focus, the taskbar falls behind and it appears how I want it to. How can I do this programmatically? Thank you!

推荐答案

这很棘手...并非我想的那么简单.

This was a toughy... Not as simple as I thought.

我最终使用了作弊并添加了VB程序集:

I ended up using a cheat and adding the VB assembly:

Add-Type -Assembly "Microsoft.VisualBasic"

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://localhost")
$ie.visible = $true
$ie.fullscreen = $true
While ($ie.Busy) { Sleep -m 10 }
$ieProc = Get-Process | ? { $_.MainWindowHandle -eq $ie.HWND }
[Microsoft.VisualBasic.Interaction]::AppActivate($ieProc.Id)

这篇关于在Powershell中聚焦IE窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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