Jump to content

Recommended Posts

Posted

I want to save a screenshot of the screen in a particular folder with different names.

like img0, img1, img2,...

I tried using the while loop first

$fileCount = 0
    $exists = 1
    While $exists = 1
        $exists = FileExists(@ScriptDir & "\searches\img" & $fileCount & ".PNG")
        ConsoleWrite(@ScriptDir & "\searches\img" & $fileCount & ".PNG")
        $fileCount = $fileCount + 1
        Sleep(100)
    WEnd

    $fileCount = $fileCount - 1
    $screenShot = _ScreenCapture_Capture("")
    _ScreenCapture_SaveImage(@ScriptDir & "\searches\img" & $fileCount & ".jpg", $screenShot)

this function does not search for the next possible file name instead it just overwrites the file with number initialized with $fileCount

then I did the same thing using do...Until loop

$fileCount = 0
    $exists = 1
    Do
        $exists = FileExists(@ScriptDir & "\searches\img" & $fileCount & ".PNG")
        ConsoleWrite(@ScriptDir & "\searches\img" & $fileCount & ".PNG")
        $fileCount = $fileCount + 1
        Sleep(100)
    Until $exists = 1

    $fileCount = $fileCount - 1
    $screenShot = _ScreenCapture_Capture("")
    _ScreenCapture_SaveImage(@ScriptDir & "\searches\img" & $fileCount & ".jpg", $screenShot)

this ends up being an infinite loop

I cant see the issue here 

i am new to autoit

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...