Skip to content

Instantly share code, notes, and snippets.

@JohnScottUK
Last active June 27, 2021 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnScottUK/abc0c9af6ec75497e693b65346a30e35 to your computer and use it in GitHub Desktop.
Save JohnScottUK/abc0c9af6ec75497e693b65346a30e35 to your computer and use it in GitHub Desktop.
Script to Control+Tab between Internet Explorer Tabs
<#
.SYNOPSIS
Rotate-Tabs rotates tabs in Internet Explorer with a delay.
.DESCRIPTION
Rotate-Tabs will rotate tabs in Internet Explorer with a delay. It first waits for 20
seconds, counting down to give you time to switch Internet Explorer to the front and
then sends Control+Tab to the browser at regular intervals to switch to the next tab.
.PARAMETER delay
An optional delay parameter used. If not provided, then the script asks for a value
and then defaults to 60 seconds if nothing provided.
.EXAMPLE
PS> Rotate-Tabs.ps1 -delay 120
.EXAMPLE
PS> Rotate-Tabs.ps1 30
#>
Param ([int32] $delay = "")
#
# Initialise...
#
[void][Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
Write-Host "Rotate Tabs V1.0."
Write-Host "Rotate between tabs in Internet Explorer."
#
# Check for -delay parameter...
#
If($delay -eq "") {
Write-Host ""
Write-Host "First open multiple tabs in Internet Explorer before returning here."
$delay = Read-Host -Prompt "Enter a delay between rotating tabs [60 Seconds]"
if($delay -eq "") {
$delay=60
}
}
#
# Allow switching to browser...
#
Write-Host ""
Write-Host "Now switch to Internet Explorer to rotate tabs every $delay seconds."
Write-Host "Press F11 or Alt+V then F to switch to full screen"
#
# Count down...
#
$remain=20
ForEach ($pause in @(5,5,5,1,1,1,1,1)) {
Write-Host "Waiting $remain seconds to start..."
Start-Sleep $pause
$remain = $remain - $pause
}
#
# Switch and Sleep...
#
Do {
Write-Host "Switching tabs..."
[System.Windows.Forms.SendKeys]::SendWait("^{TAB}")
Write-Host "Sleeping $delay seconds to switch..."
Start-Sleep -Seconds $delay
} While ($i -ne 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment