PowerShell/scripts/switch-tabs.ps1

33 lines
996 B
PowerShell
Raw Normal View History

2024-10-01 15:24:16 +02:00
<#
2023-03-19 19:27:52 +01:00
.SYNOPSIS
Switches Web browser tabs
2023-03-19 19:27:52 +01:00
.DESCRIPTION
This PowerShell script switches automatically from tab to tab every <n> seconds (by pressing Ctrl + PageDown).
.PARAMETER timeInterval
Specifies the time interval in seconds (10sec per default)
2023-03-19 19:27:52 +01:00
.EXAMPLE
PS> ./switch-tabs.ps1
Switching from tab to tab automatically every 10 seconds...
(click the Web browser to activate it - press <Ctrl C> here to stop it)
2023-03-19 19:27:52 +01:00
.NOTES
Author: Markus Fleschutz / License: CC0
2023-03-19 19:27:52 +01:00
.LINK
https://github.com/fleschutz/PowerShell
2023-03-19 19:27:52 +01:00
#>
param([int]$timeInterval = 10) # in seconds
2023-03-19 19:27:52 +01:00
try {
Write-Host "⏳ Switching from tab to tab automatically every $timeInterval seconds..."
Write-Host " (click the Web browser to activate it - press <Ctrl C> here to stop it)"
2023-03-19 19:27:52 +01:00
$obj = New-Object -com wscript.shell
2023-03-30 11:36:38 +02:00
while ($true) {
2023-03-19 19:27:52 +01:00
$obj.SendKeys("^{PGDN}")
Start-Sleep -seconds $timeInterval
2023-03-19 19:27:52 +01:00
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2023-03-19 19:27:52 +01:00
exit 1
}