-
-
Save voidproc/b18266598a3312145d33c9b43d61f9cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rui = $Host.UI.RawUI | |
$pos = New-Object System.Management.Automation.Host.Coordinates 0,($rui.CursorPosition.Y - 1) | |
# Drop ghost 'Enter' keyup | |
$rui.ReadKey("NoEcho,IncludeKeyUp") >$null | |
while ($true) | |
{ | |
$cputime = ((Get-WmiObject Win32_PerfFormattedData_PerfOS_Processor).PercentProcessorTime)[0] | |
$rui.CursorPosition = $pos | |
Write-Host "${cputime}% ".PadLeft(5) -ForegroundColor Green -NoNewline | |
Write-Host ("`#" * [Math]::Truncate($cputime[0] * 20 / 100)).PadRight(20) -ForegroundColor Green -BackgroundColor Black -NoNewline | |
1..10 | ForEach-Object { | |
if ($rui.KeyAvailable) | |
{ | |
$vk = $rui.Readkey("NoEcho,IncludeKeyUp,IncludeKeyDown").VirtualKeyCode | |
if ($vk -ne 16 -and $vk -ne 17 -and $vk -ne 18) { break } # modifiers | |
} | |
Start-Sleep -Milliseconds (1000/10) | |
} | |
} | |
$rui.CursorPosition = $pos | |
Write-Host (" " * $rui.WindowSize.Width) -NoNewline | |
$rui.CursorPosition = $pos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment