如何使用Powershell提出IE窗口

时间:2018-10-16 11:55:28

标签: powershell

我有以下powershell命令,该命令将基于REST API调用在用户PC上按计划运行,以了解他们是否尚未提交时间表。

它工作正常,但是我想此时将IE窗口作为主窗口。

$msgBoxInput =  [System.Windows.MessageBox]::Show('You havent submitted the timesheet. Please do it now','xyz is watching you','OK','Error')
 $IE=new-object -com internetexplorer.application
$IE.navigate2("www.microsoft.com")
$IE.visible=$true

Powershell可以使用吗?轻松地

1 个答案:

答案 0 :(得分:1)

应该可行。 看这个例子:

## Find all Active Windows Titles
$windows=Get-Process | Where-Object {$_.MainWindowTitle -ne ""} | Select-Object MainWindowTitle
## Find Specific name 
$WindowTitle=($windows | ? {$_ -match "Internet Explorer"} ).MainWindowTitle
## Add Type and Focus Activate the Window
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate($WindowTitle)

只需确保您具有正确的MainWindowTitle。
希望对您有帮助

相关问题