IE 根据星期几打开不同的选项卡

21 internet-explorer-11

当我在一周的不同天打开 IE 时,我希望自动打开不同的选项卡。

我必须为一周中的每一天运行不同的工作报告,打开 5-10 个选项卡来运行报告需要花费大量时间。如果当我打开 IE 时,我需要的选项卡会自动加载并准备好供我使用,那么速度会快很多。

有没有办法在 IE 中根据星期几打开 5-10 个不同的选项卡?

示例:
周一 - 6 个会计页面
周二 - 7 个计费页面
周三 - 5 个人力资源页面
周四 - 10 个计划页面
周五 - 8 个工作总结/订单页面

Jul*_*ght 34

与其尝试蛮力方法,不如另辟蹊径?

在不同的窗口中或一次打开一组选项卡,然后将所有选项卡保存到书签文件夹中。将文件夹放在书签工具栏上以便于访问。

在每一天,右键单击文件夹并单击打开所有选项卡。

如果您愿意,可以将所有日常文件夹放入顶级文件夹以节省空间,但需要额外单击才能访问它们。

如果你真的必须更进一步,你需要编写一个程序或脚本来驱动 IE。最简单的方法可能是编写一个 PowerShell 脚本。

  • “最简单的方法可能是编写一个 PowerShell 脚本。” 我同意,所以我 [in my answer] (http://superuser.com/a/751691/23133) 删除了一个。:) (3认同)
  • 我真的很喜欢 PowerShell。很棒的脚本环境。 (2认同)

Ƭᴇc*_*007 34

您可以使用 PowerShell 自动化 IE:

我推到一起的这个示例脚本会找出今天是哪一天,并用一组标签打开 IE:

# Arrays of sites to open; one for each day of the week.
$mondaySites = @("http://www.google.com", "http://www.yahoo.com", "http://www.bing.com")
$tuesdaySites = @("http://www.intel.com","http://www.apple.com","http://www.ubuntu.com/","http://www.android.com/", "http://www.microsoft.com")
$fridaySites = @("http://www.superuser.com", "http://www.cnn.com","http://www.bbc.com/news/world/","http://www.reddit.com/r/funny/")

$sitesToOpen = @()

# Get the day of the week
$today = (get-date).DayOfWeek

# Depending on the day of the week discovered, assign the right day's array into the sitesToOpen array.
switch ($today) { 
        "Monday" {$sitesToOpen = $mondaySites} 
        "Tuesday" {$sitesToOpen = $tuesdaySites} 
        "Friday" {$sitesToOpen = $fridaySites}
    }

# Use COM to create a new IE instance.    
$ie = new-object -com "InternetExplorer.Application"

$isFirstSite = $true

# Loop through the array of sites, and navigate our IE instance to them.
foreach ($site in $sitesToOpen) {
        If ($isFirstSite) {
            $ie.Navigate2($site)
            $isFirstSite = $false
        } else {
            # If it's not the first site, then include the flag to open the site in a new tab.
            $ie.Navigate2($site, 0x10000)
        }
    }

# Show the IE window.    
$ie.Visible = $true
Run Code Online (Sandbox Code Playgroud)

注意:我只做了三天的站点阵列,您需要在需要处理的其他日子添加其他站点阵列。:)

  • @JulianKnight 就个人而言,我认为您的方法要好得多。即使作为开发人员,我也更愿意为每天维护一个可以在 IE 中轻松管理的书签文件夹,而不是需要编辑和存储在某处的脚本。如果列表是动态的,Powershell 方法将是完美的,但我认为这个请求不需要。 (2认同)

Dav*_*ave 7

我不建议它与 IE 一起使用,因为它不是内置的......你需要一个解决方法或类似的方法。

使用 FireFox,您可以通过编写一个小的 bat 文件来完成。您不必打开浏览器,而是必须运行 .bat 文件,该文件将使用所选选项卡打开 FireFox

@ECHO OFF

SET BROWSER=firefox.exe
START %BROWSER% -new-tab "google.com"
START %BROWSER% -new-tab "http://superuser.com"
START %BROWSER% -new-tab "stackexchange.com" 
Run Code Online (Sandbox Code Playgroud)

就个人而言,我会保存几个不同的版本(每周)。您甚至可以有一个脚本来在早上第一次登录时打开页面。

如果您必须使用 IE,那么您每天都会使用类似的概念,当您第一次登录时,您将运行一个脚本来为您更新注册表。将以下内容另存为 .reg 文件并运行它(记住,先备份以防万一)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"Start Page"="http://www.yahoo.com"
reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main" /t REG_MULTI_SZ /v "Secondary Start Pages" /d "http://www.bbc.co.uk\0http://www.superuser.com\0" /f
Run Code Online (Sandbox Code Playgroud)

因此,您将拥有其中 5 个文件,并且一整天,当您打开 IE 时,它将拥有您想要的设置。

  • @edvinas.me `-new` 参数自 IE 7 起已过时。 [来源](http://msdn.microsoft.com/en-us/library/ie/hh826025%28v=vs.85%29.aspx ) (3认同)

and*_*415 5

预备步骤

  1. AutoLoad在 Internet Explorer (IE) 收藏夹中创建一个文件夹。

  2. 在您刚刚创建的文件夹中创建七个子文件夹,编号从06。最终结果应如下所示:

    收藏夹

    每个数字对应一周中的一天:

    • 0 - 星期日
    • 1 - 周一
    • 2 - 周二
    • 3 - 周三
    • 4 - 周四
    • 5 - 星期五
    • 6 - 周六

  3. 根据需要将要打开的页面放在每个子文件夹中。

批处理脚本

复制以下代码并将其粘贴到名为 的新文件中SetIEPages.cmd

@echo off
setlocal
setlocal enabledelayedexpansion

call :getWeekday

REM set the working directory
set dir=%userprofile%\Favorites\AutoLoad\%weekday%

REM ensure the directory exists
if not exist "%dir%\" exit /b 2

pushd "%dir%"

set pages=
set /a counter=1
set key=HKCU\Software\Microsoft\Internet Explorer\Main

REM loop through all favorites links
for %%A in (*.url) do (

REM get the URL
for /f "usebackq delims=" %%B in (
`type "%%~A" ^| find /i "URL="`
) do (

set url=%%~B
set url=!url:~4!

REM check whether the URL is empty
if defined url (

if !counter! geq 2 (
set pages=!pages!"!url!"\0
) else (

REM set the start page
reg add "%key%" /v "Start Page" /t REG_SZ /d "!url!" /f >nul

REM clear the secondary pages
reg delete "%key%" /v "Secondary Start Pages" /f >nul 2>&1
)

REM increase the URL counter
set /a counter += 1
)))

if defined pages (
set pages=!pages:~0,-2!

REM set the seconday pages
reg add "%key%" /v "Secondary Start Pages" /t REG_MULTI_SZ /d "!pages!" /f >nul
)

popd
endlocal & exit /b

:getWeekday
for /f "usebackq tokens=2 delims==" %%G in (
`wmic path Win32_LocalTime get dayofweek /value ^| findstr /c:"="`
) do set weekday=%%G
exit /b
Run Code Online (Sandbox Code Playgroud)

这个怎么运作

该脚本检索当前星期几,然后用于构建包含每日页面的路径。然后扫描目标文件夹中所有可用的收藏链接,获取每个链接的 URL。最后设置 IE 起始页。浏览器启动后,所选页面将自动加载。连同下面的计划任务,这使事情以一劳永逸的方式工作。

定时任务

  1. Win+ R,键入或粘贴taskschd.msc,然后按Enter
  2. 单击操作 > 创建任务。命名它SetIEPages
  3. 在“常规”选项卡中,单击“更改用户或组”
  4. 键入您的用户帐户名称,单击检查名称,然后单击确定
  5. 选择无论用户是否登录都运行选项,然后选中不存储密码选项。
  6. 选择触发器选项卡,然后单击新建
  7. 更改开始执行任务,以在日志上
  8. 单击特定用户选项,并确保选择了您的用户帐户。然后单击确定
  9. 切换到操作选项卡,然后单击新建
  10. "X:\Path\to\SetIEPages.cmd"Program/script文本框中键入,将其替换为实际文件路径。
  11. 单击条件选项卡,然后取消选中仅在计算机使用交流电源时启动任务选项。
  12. 错过计划的启动后尽快启用运行任务选项。
  13. 将所有其他设置保留为默认值,然后单击确定