I\'m running a script that takes a screenshot and saves to file. I\'m a novice and having trouble integrating mouse events so for now I\'m going to complete part of my task manu
You can do something like this:
$i = 0 do { $i++ $File = "C:\Users\mydirectory\image$i.bmp" } until (-not (Test-Path -LiteralPath $File) -or $i -ge 500)
That increments the number ($i) until a non-existing filename is found or $i reaches 500.
$i