akshatgupta Posted February 22, 2018 Posted February 22, 2018 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
KickStarter15 Posted February 22, 2018 Posted February 22, 2018 Why not use FileFindFirstFile() and FileFindNextFile() functions, check with help file. something like this: $sFilePath = @ScriptDir & "\" $hSearch = FileFindFirstFile($sFilePath & "*.png") $aFileName = FileFindNextFile($hSearch) Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.
akshatgupta Posted February 22, 2018 Author Posted February 22, 2018 1 hour ago, KickStarter15 said: Why not use FileFindFirstFile() and FileFindNextFile() functions, check with help file. something like this: $sFilePath = @ScriptDir & "\" $hSearch = FileFindFirstFile($sFilePath & "*.png") $aFileName = FileFindNextFile($hSearch) it worked thanks
KickStarter15 Posted February 22, 2018 Posted February 22, 2018 Welc's... Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now