Update write-marquee.ps1

This commit is contained in:
Markus Fleschutz 2022-10-03 11:43:42 +02:00
parent 7489b8501d
commit ce70b5e32b

View File

@ -2,7 +2,7 @@
.SYNOPSIS .SYNOPSIS
Writes text as marquee Writes text as marquee
.DESCRIPTION .DESCRIPTION
This PowerShell script writes text as marquee. This PowerShell script writes the given text as marquee.
.PARAMETER text .PARAMETER text
Specifies the text to write Specifies the text to write
.PARAMETER speed .PARAMETER speed
@ -15,31 +15,24 @@
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$text = "PowerShell is powerful! PowerShell is cross-platform! PowerShell is open-source! PowerShell is easy to learn! Powershell is fully documented", [int]$speed = 60) # 60 ms pause param([string]$Text = "PowerShell is powerful - fully control your computer! PowerShell is cross-platform - available for Linux, Mac OS and Windows! PowerShell is open-source and free - see the GitHub repository at github.com/PowerShell/PowerShell! PowerShell is easy to learn - see the tutorial for beginners at guru99.com/powershell-tutorial.html! Powershell is fully documented - see the official PowerShell documentation at docs.microsoft.com/en-us/powershell", [int]$Speed = 60) # 60 ms pause
function StartMarquee { param([string]$text) function StartMarquee { param([string]$Line)
$Length = $text.Length "╔══════════════════════════════════════════════════════════════════════════════════╗"
$Start = 1 "║ ║"
$End = ($Length - 80) "╚══════════════════════════════════════════════════════════════════════════════════╝"
$LinePos = $HOST.UI.RawUI.CursorPosition
clear-host $LinePos.X = 2
write-output "" $LinePos.Y -= 2
write-output "------------------------------------------------------------------------------------" foreach($Pos in 1 .. $($Line.Length - 80)) {
$StartPosition = $HOST.UI.RawUI.CursorPosition $HOST.UI.RawUI.CursorPosition = $LinePos
$StartPosition.X = 2 Write-Host -noNewLine "$($Line.Substring($Pos,80))"
write-output "| |" Start-Sleep -milliseconds $Speed
write-output "------------------------------------------------------------------------------------"
foreach ($Pos in $Start .. $End) {
$HOST.UI.RawUI.CursorPosition = $StartPosition
$TextToDisplay = $text.Substring($Pos, 80)
write-host -nonewline $TextToDisplay
start-sleep -milliseconds $speed
} }
write-output "" " "
write-output "" " "
write-output "" " "
} }
StartMarquee " +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ " StartMarquee " +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ "
exit 0 # success exit 0 # success