Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Nested Next Inside If

$
0
0
Hello all,

I have a For Statement that is reading lines from a file. I have been trying to figure out how to continue to the next line within the file (when a condition is met...or lack thereof), otherwise do other things and then go to the next line. Essentially I'm creating a timeout for a window wait and if the window never shows, I want to continue to the next document in the file. Is it possible to nest a Next inside an If statement or is there some other trick?

I currently get the whole ""Next" statement with no matching "For" statement." error...but there is a For statement...it just doesn't seem to be able to see it from within the If.

If you are wondering what I'm trying to do, it's strip passwords from office files (where the password is known). :thumbsup:

[ autoit ]         
;Read XREF to an Array Dim $AttLoc If Not _FileReadToArray($XREF,$AttLoc) Then MsgBox(4096,"Error", " Error reading XREF to an Array ErrorID: " & @error) Return EndIf ;Create Progress Bar For Report Creation ProgressOn("Working...", "Saving Documents Without Passwords", "Currently Processing item 1 of " & $AttLoc[0],5,5,17) ;Start Of Loop For $x = 1 to $AttLoc[0] $File = "" $line = "" $inLine = "" $inPath = "" $inPass = "" $inSplit = "" If $AttLoc[$x] <> "" Then $inLine = StringSplit($AttLoc[$x],' ') $inPath = $inLine[1] $inPass = $inLine[2] $inSplit = _PathSplit($inPath, $szDrive, $szDir, $szFName, $szExt) $inSplit = $inSplit[3]&$inSplit[4] EndIf ProgressSet(100 * $x / $AttLoc[0], "Currently Processing item " & $x & " of " & $AttLoc[0]&@LF&@LF&$inSplit) ;Write To Report If FileExists($inPath) =0 Then If $inPath = "" Then ;Do Nothing Else FileWrite($LOG, "File Does Not Exist - "&$inPath&@CRLF) EndIf ElseIf FileExists($inPath) Then FileWrite($LOG,"File Processed: "&$inPath&@CRLF) EndIf If FileExists($inPath) Then ;Check Selection Type If $xlsSet = $GUI_CHECKED Then ShellExecute($inPath) While WinExists("Microsoft Excel","") = 0 Wend If WinWait("Password","",15) =0 Then MsgBox(16,"Timeout","15 seconds passed without window detection",3) FileWrite($LOG, "Timeout - "&$inPath&@CRLF) Next Else WinActivate("Password","") ControlClick("Password","",20) AutoItSetOption("SendKeyDelay",200) Sleep(200) Send($inPass&"{ENTER}") ;Ect...Ect... EndIf ;More Code...More Code... EndIf Next

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>