forked from nickrod518/PowerShell-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrite-Type.ps1
More file actions
49 lines (38 loc) · 1.41 KB
/
Copy pathWrite-Type.ps1
File metadata and controls
49 lines (38 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function Write-Type {
<#
.Synopsis
Make Write-Host text appear as if it is being typed
.DESCRIPTION
Input text and if desired specify the write speed (25-500 milliseconds) and foreground color for the text
.EXAMPLE
Write-Typewriter 'Hello world!'
.EXAMPLE
Write-Typewriter 'Hello world!' 250
.EXAMPLE
Write-Typewriter -Text '2 spooky 4 me!' -TypeSpeed 400 -ForegroundColor 'Red'
.NOTES
v1.1 - 2016-04-04 - Nick Rodriguez
-Changed name
-Changed TypeSpeed range
-Added ForegroundColor param
-Changed sleep to not use method after seeing it slow performance with Measure-Command
-Changed code formatting to my liking
v1.0 - 2016-01-25 - Nathan Kasco (http://poshcode.org/6193)
#>
[CmdletBinding()]
[OutputType([string])]
param (
[Parameter(Mandatory = $true, Position = 0)]
[string] $Text,
[Parameter(Mandatory = $false, Position = 1)]
[ValidateRange(25, 500)]
[int] $TypeSpeed = 125,
[Parameter(Mandatory = $false, Position = 2)]
[string] $ForegroundColor = 'White'
)
# Pause after typing each letter
$Text.GetEnumerator() | ForEach-Object {
Write-Host $_ -NoNewline -ForegroundColor $ForegroundColor
Start-Sleep -Milliseconds $TypeSpeed
}
}