I want to simulate the human input with POWERSHELL, below is a sample code, I want to see the animation effect in I run the code, and gif but it’s still not good enough.
Any good idea? convert string to an array of letter, then print each letter? how about the delay of input, how to get a random delay for each letter?
$string = "This is a sample string."
# Split the string into an array of words.
$words = $string.Split()
# Iterate over the array and print each word.
foreach ($word in $words) {
Write-Host -NoNewLine "$word " -ForegroundColor Blue
Start-Sleep -Milliseconds 100
}
# Print a newline at the end.
Write-Host
I change it to below code, but I don’t understand why if statement never run even the boolean value is true, the $true argument isn’t pass to the function correctly? anyone can help to check?