Rogue5099 Posted April 2, 2014 Share Posted April 2, 2014 (edited) Edit: StringRegExpReplace not StringRegExp Sorry With the following code: #include <ScreenCapture.au3> DirCreate(@ScriptDir & "\SS\") For $i = 9 To 10 Local $sOutput = StringRegExpReplace("Screen" & $i & ".jpg", "([a-zA-Z]+)(\d{1})(\..+)", "${1}00$2$3") ConsoleWrite($sOutput & @CRLF) ;~ If Not FileExists(@ScriptDir & "\SS\" & $sOutput) Then ;~ _ScreenCapture_Capture(@ScriptDir & "\SS\" & $sOutput) ;~ ExitLoop ;~ EndIf Next I can get it to output, Screen009.jpg Screen10.jpg But I would like: Screen009.jpg Screen010.jpg and if in 100's I would like, Screen100.jpg so on. Also would there be a better way to execute this than checking 1 to 999? Lets say program was restarted at Screen500.jpg it would start at 500 and next time start at 501 within program? Below is what I thought of while typing the question above but there might be a better solution to this as well. #include <ScreenCapture.au3> $LastScreen = _ScreenSave(9) MsgBox(), "Test", "Last Screen .jpg saved was " & $LastScreen) Func _ScreenSave($iLastScreen) Local $iLastScreen, $sOutput DirCreate(@ScriptDir & "\SS\") For $i = $iLastScreen To 10 $sOutput = StringRegExpReplace("Screen" & $i & ".jpg", "([a-zA-Z]+)(\d{1})(\..+)", "${1}00$2$3") If Not FileExists(@ScriptDir & "\SS\" & $sOutput) Then _ScreenCapture_Capture(@ScriptDir & "\SS\" & $sOutput) Return $i EndIf Next EndFunc Edited April 2, 2014 by Rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Iczer Posted April 2, 2014 Share Posted April 2, 2014 Local $sOutput = Execute(StringRegExpReplace("Screen" & $i & ".jpg", "([a-zA-Z]+)(\d{1,9})(\..+)", "'${1}'&StringFormat('%03d',$2)&'$3'")) Link to comment Share on other sites More sharing options...
Rogue5099 Posted April 2, 2014 Author Share Posted April 2, 2014 Local $sOutput = Execute(StringRegExpReplace("Screen" & $i & ".jpg", "([a-zA-Z]+)(\d{1,9})(\..+)", "'${1}'&StringFormat('%03d',$2)&'$3'")) Thank you works great! My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
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