2023-03-19 19:27:52 +01:00
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
2023-03-20 07:57:12 +01:00
|
|
|
Switches browser tabs
|
2023-03-19 19:27:52 +01:00
|
|
|
.DESCRIPTION
|
2023-03-20 07:57:12 +01:00
|
|
|
This PowerShell script switches browser tabs automatically every <n> seconds (by pressing Ctrl + PageDown).
|
2023-03-19 19:27:52 +01:00
|
|
|
.EXAMPLE
|
|
|
|
PS> ./switch-tabs
|
|
|
|
.NOTES
|
2023-03-20 07:57:12 +01:00
|
|
|
Author: Markus Fleschutz / License: CC0
|
2023-03-19 19:27:52 +01:00
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/talk2windows
|
|
|
|
#>
|
|
|
|
|
|
|
|
param([int]$Interval = 5) # in seconds
|
|
|
|
|
|
|
|
try {
|
2023-03-20 07:57:12 +01:00
|
|
|
Write-Host "Switching browser tabs automatically every $Interval seconds."
|
|
|
|
Write-Host "Click into the browser window to activate it (press Ctrl + C here to stop it)..." -noNewline
|
2023-03-19 19:27:52 +01:00
|
|
|
$obj = New-Object -com wscript.shell
|
|
|
|
for ([int]$i = 0; $i -lt 1000; $i++) {
|
|
|
|
Write-Host "." -noNewline
|
|
|
|
$obj.SendKeys("^{PGDN}")
|
|
|
|
Start-Sleep -seconds $Interval
|
|
|
|
}
|
|
|
|
exit 0 # success
|
|
|
|
} catch {
|
2023-03-20 07:57:12 +01:00
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2023-03-19 19:27:52 +01:00
|
|
|
exit 1
|
|
|
|
}
|