PowerShell/scripts/switch-tabs.ps1

31 lines
834 B
PowerShell
Raw Normal View History

2023-10-31 11:25:11 +01:00
<#
2023-03-19 19:27:52 +01:00
.SYNOPSIS
Switches browser tabs
2023-03-19 19:27:52 +01:00
.DESCRIPTION
This PowerShell script switches browser tabs automatically every <n> seconds (by pressing Ctrl + PageDown).
2023-03-30 11:36:38 +02:00
.PARAMETER Interval
Specifies the switch interval in seconds (10 sec per default)
2023-03-19 19:27:52 +01:00
.EXAMPLE
PS> ./switch-tabs
.NOTES
Author: Markus Fleschutz / License: CC0
2023-03-19 19:27:52 +01:00
.LINK
https://github.com/fleschutz/talk2windows
#>
2023-03-30 11:36:38 +02:00
param([int]$Interval = 10) # in seconds
2023-03-19 19:27:52 +01:00
try {
2023-03-30 11:38:35 +02: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)"
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 $Interval
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2023-03-19 19:27:52 +01:00
exit 1
}