Powershell: Typist | Zak Emerick's IT Blog

My IT blog for random ideas and solutions.

Powershell: Typist


Replaces key input with sections from a file. 
Will read from a text file of your choosing and replaces your keystrokes with random sections of the file.
Just a novelty script.
 This param is required.
Powershell.exe -file Typist.ps1 -FilePath CodeFile.cs
 The maximum parameter will determine the the ceiling of the random number generator.
Powershell.exe -file Typist.ps1 -FilePath CodeFile.cs -Maximum 40
    [int]$Maximum = 10,
begin {
    $content = Get-content $FilePath | Out-String
    $s = 0
    if ($Maximum -ge $content.Length) { 
        Write-Host "Error: Maximum range $($Maximum) is greater than content size of $($content.Length)" -ForegroundColor Red
Process {
    [int]$c = $content.Length
    while (!$Error) {
        $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | Out-Null
        $r = Get-Random -Minimum 1 -Maximum $Maximum
        try { 
            Write-Host "$($content.Substring($s,$r))" -NoNewline
            $s += $r
            $c -= $r
        } catch {
            $wshell = New-Object -ComObject wscript.shell;
end {}

A simple novelty script I wrote today to mimic hackertyper.net . It could have been a little cleaner, but for what it is– it works just fine!

1066 Total Views 1 Views Today

Post a Comment

Your email address will not be published. Required fields are marked *

 characters available