![配置桌面 IE 快捷方式以查找并聚焦现有窗口](https://linux22.com/image/1497055/%E9%85%8D%E7%BD%AE%E6%A1%8C%E9%9D%A2%20IE%20%E5%BF%AB%E6%8D%B7%E6%96%B9%E5%BC%8F%E4%BB%A5%E6%9F%A5%E6%89%BE%E5%B9%B6%E8%81%9A%E7%84%A6%E7%8E%B0%E6%9C%89%E7%AA%97%E5%8F%A3.png)
使用 Windows 7 和 Internet Explorer 9(或更高版本),我尝试创建指向特定网页的桌面快捷方式。诀窍是,如果用户已在任何 IE 窗口中打开该网页,我需要快捷方式来聚焦到该窗口,而不是创建一个新窗口。
答案1
此 powershell 脚本查看所有当前 IE URL,如果没有打开 google,则打开 google.com,否则不执行任何操作。您需要将“*google”更改为“*yourbaseURLname”,将“www.google.com”更改为“www.yourwebsite.com”。(脚本最后 5 行)
将其保存为 .ps1 文件。
Function GetCurrentIEURL
{
$IEObjs = @()
$ShellWindows = (New-Object -ComObject Shell.Application).Windows()
Foreach($IE in $ShellWindows)
{
$FullName = $IE.FullName
If($FullName -ne $NULL)
{
$FileName = Split-Path -Path $FullName -Leaf
If($FileName.ToLower() -eq "iexplore.exe")
{
$Title = $IE.LocationName
$URL = $IE.LocationURL
$IEObj = New-Object -TypeName PSObject -Property @{Title = $Title; URL = $URL}
$IEObjs += $IEObj
}
}
}
$IEObjs
}
$CurrentIEURL = GetCurrentIEURL
if ($CurrentIEURL -NotContains "*google")
{
$IE=new-object -com internetexplorer.application
$IE.navigate2("www.google.com")
$IE.visible=$true
}