Something got wrong posting, look on post nr 2
This is a quite fun script.
-
How do I get it to make the animation in a textbox in a GUI in Powershell?
-
How do I stop the animation with, lets say a button-click?
-
Is there a better way to aniamte | / - \ | / - \ in powershell in a textbox.
function BlastFromThePast([switch]$EndOfLine, [switch]$Finished){ $EscChar = "`r" if($EndOfLine){ $EscChar = "`b" } if($Finished){Write-Host "$EscChar"; return;} if(!$tickcounter){ Set-Variable -Name "tickcounter" -Scope global -Value 0 -Force -Option AllScope } if(!$tickoption){ Set-Variable -Name "tickoption" -Scope global -Value 0 -Force -Option AllScope } $chance = Get-Random -Minimum 1 -Maximum 10 if($chance -eq 5){ if($tickoption -eq 1){$tickoption = 0}else{$tickoption = 1} } switch($tickoption){ 0 { switch($tickcounter){ 0 { Write-Host "$EscChar|"} 1 { Write-Host "$EscChar/"} 2 { Write-Host "$EscChar-"} 3 { Write-Host "$EscChar\"} } break; } 1 { switch($tickcounter){ 0 { Write-Host "$EscChar|"} 1 { Write-Host "$EscChar/"} 2 { Write-Host "$EscChar-"} 3 { Write-Host "$EscChar\"} } break; } } if($tickcounter -eq 3){ $tickcounter = 0 } else{ $tickcounter++ } } for($i=0;$i-lt200;$i++){BlastFromThePast; Start-Sleep -Milliseconds 100}Write-Host "`r" -no
you would have to run it as a back-ground job. Maybe check out the articles on sapiens forum about interactive gui’s.