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
Writes text as marquee
.DESCRIPTION
This PowerShell script writes text as marquee.
This PowerShell script writes the given text as marquee.
.PARAMETER text
Specifies the text to write
.PARAMETER speed
@ -15,31 +15,24 @@
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)
$Length = $text.Length
$Start = 1
$End = ($Length - 80)
clear-host
write-output ""
write-output "------------------------------------------------------------------------------------"
$StartPosition = $HOST.UI.RawUI.CursorPosition
$StartPosition.X = 2
write-output "| |"
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
function StartMarquee { param([string]$Line)
"╔══════════════════════════════════════════════════════════════════════════════════╗"
"║ ║"
"╚══════════════════════════════════════════════════════════════════════════════════╝"
$LinePos = $HOST.UI.RawUI.CursorPosition
$LinePos.X = 2
$LinePos.Y -= 2
foreach($Pos in 1 .. $($Line.Length - 80)) {
$HOST.UI.RawUI.CursorPosition = $LinePos
Write-Host -noNewLine "$($Line.Substring($Pos,80))"
Start-Sleep -milliseconds $Speed
}
write-output ""
write-output ""
write-output ""
" "
" "
" "
}
StartMarquee " +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ $text +++ "
exit 0 # success
StartMarquee " +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ "
exit 0 # success