2021-02-06 14:38:58 +01:00
|
|
|
<#
|
2021-04-07 15:17:49 +02:00
|
|
|
.SYNTAX write-animated.ps1 [<line1>] .. [line9>] [<speed>]
|
2021-03-22 20:10:18 +01:00
|
|
|
.DESCRIPTION writes animated text
|
|
|
|
.LINK https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES Author: Markus Fleschutz / License: CC0
|
2021-02-06 14:38:58 +01:00
|
|
|
#>
|
|
|
|
|
2021-05-04 20:01:31 +02:00
|
|
|
param($Line1 = "", $Line2 = "", $Line3 = "", $Line4 = "", $Line5 = "", $Line6 = "", $Line7 = "", $Line8 = "", $Line9 = "", [int]$Speed = 40) # 40 ms pause
|
2021-02-06 14:38:58 +01:00
|
|
|
|
2021-04-22 08:56:07 +02:00
|
|
|
$TerminalWidth = 120 # characters
|
|
|
|
|
2021-02-06 14:38:58 +01:00
|
|
|
function WriteAnimatedLine { param([string]$Line, [int]$Speed)
|
|
|
|
[int]$Start = 1
|
|
|
|
[int]$End = $Line.Length
|
|
|
|
$StartPosition = $HOST.UI.RawUI.CursorPosition
|
|
|
|
$Spaces = " "
|
|
|
|
|
|
|
|
if ($Line -ne "") {
|
|
|
|
foreach ($Pos in $Start .. $End) {
|
2021-04-22 08:56:07 +02:00
|
|
|
$TextToDisplay = $Spaces.Substring(0, $TerminalWidth / 2 - $pos / 2) + $Line.Substring(0, $Pos)
|
2021-02-06 14:38:58 +01:00
|
|
|
write-host -nonewline $TextToDisplay
|
|
|
|
start-sleep -milliseconds $Speed
|
|
|
|
$HOST.UI.RawUI.CursorPosition = $StartPosition
|
|
|
|
}
|
|
|
|
write-host ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($Line1 -eq "") {
|
|
|
|
$Line1 = "Welcome to PowerShell Scripts"
|
|
|
|
$Line2 = ""
|
|
|
|
$Line3 = "This repository contains useful and cross-platform PowerShell scripts."
|
|
|
|
$Line4 = "Send your e-mail feedback to: markus@fleschutz.de"
|
|
|
|
$Line5 = "Best regards,"
|
|
|
|
$Line6 = "Markus"
|
|
|
|
}
|
|
|
|
write-host ""
|
|
|
|
WriteAnimatedLine $Line1 $Speed
|
|
|
|
WriteAnimatedLine $Line2 $Speed
|
|
|
|
WriteAnimatedLine $Line3 $Speed
|
|
|
|
WriteAnimatedLine $Line4 $Speed
|
|
|
|
WriteAnimatedLine $Line5 $Speed
|
|
|
|
WriteAnimatedLine $Line6 $Speed
|
|
|
|
WriteAnimatedLine $Line7 $Speed
|
|
|
|
WriteAnimatedLine $Line8 $Speed
|
|
|
|
WriteAnimatedLine $Line9 $Speed
|
2021-02-06 14:44:58 +01:00
|
|
|
write-host ""
|
2021-02-06 14:38:58 +01:00
|
|
|
exit 0
|