PowerShell/Docs/write-marquee.md
2023-07-29 10:17:33 +02:00

3.7 KiB

PS> ./write-marquee.ps1

This PowerShell script writes the given text as marquee.

Parameters

PS> ./write-marquee.ps1 [[-Text] <String>] [[-Speed] <Int32>] [<CommonParameters>]

-Text <String>
    Specifies the text to write
    
    Required?                    false
    Position?                    1
    Default value                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
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Speed <Int32>
    Specifies the marquee speed (60 ms per default)
    
    Required?                    false
    Position?                    2
    Default value                60
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

Example

PS> ./write-marquee "Hello World"

Notes

Author: Markus Fleschutz | License: CC0

https://github.com/fleschutz/PowerShell

Script Content

<#
.SYNOPSIS
	Writes text as marquee
.DESCRIPTION
	This PowerShell script writes the given text as marquee.
.PARAMETER text
	Specifies the text to write
.PARAMETER speed
	Specifies the marquee speed (60 ms per default)
.EXAMPLE
	PS> ./write-marquee "Hello World"
.LINK
	https://github.com/fleschutz/PowerShell
.NOTES
	Author: Markus Fleschutz | License: CC0
#>

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]$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
	}
	" "
	" "
	" "
}

StartMarquee "                                                                                    +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++                                                                                         "
exit 0 # success

(generated by convert-ps2md.ps1 using the comment-based help of write-marquee.ps1 as of 07/29/2023 10:17:27)