Focus IE window in powershell

橙三吉。 提交于 2019-12-02 04:46:19

问题


My code:

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

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!


回答1:


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

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)


来源:https://stackoverflow.com/questions/27282919/focus-ie-window-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!