From ce70b5e32b82a0ff1b90d424963218159f2fa605 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Mon, 3 Oct 2022 11:43:42 +0200 Subject: [PATCH] Update write-marquee.ps1 --- Scripts/write-marquee.ps1 | 43 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/Scripts/write-marquee.ps1 b/Scripts/write-marquee.ps1 index c5e13222..0c45bcab 100755 --- a/Scripts/write-marquee.ps1 +++ b/Scripts/write-marquee.ps1 @@ -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 \ No newline at end of file