Vote count: 0
I have a loop that interacts with my browser and I'd like to break the loop when 'z' is pressed.
$x = New-Object -ComObject wscript.shell;
while ($true) {
$x.AppActivate('Browser Window');
$x.SendKeys('x');
Start-Sleep -Seconds 3;
}
How would I create a condition in my loop that breaks it when z is pressed without having to stop for user input, if possible?
PSVersion output:
Major Minor Build Revision
----- ----- ----- --------
5 1 14393 206
asked 58 secs ago
PowerShell break loop while other window's active
Aucun commentaire:
Enregistrer un commentaire