TheMysteries Posted February 18, 2017 Share Posted February 18, 2017 Hey, i'm trying to make a loopback function that if statement = Found it should keep clicking untill statement = Not found But I can't figure out how to make that line of text This is what I got: Local $iCount = 1 While FileExists("C:\window2.txt") = 0 If $iCount = 50 Then $iCount = 0 ExitLoop EndIf $iCount += 1 WEnd If $iCount Then ConsoleWrite("Found") Else ConsoleWrite("NOT Found") EndIf Link to comment Share on other sites More sharing options...
Subz Posted February 18, 2017 Share Posted February 18, 2017 (edited) Try: CheckFileExists('C:\Windows2.txt') Func CheckFileExists($sString) For $i = 1 To 50 If FileExists($sString) = 1 Then Return 'Found' EndIf Sleep(100) Next Return 'Not Found' EndFunc Edited February 19, 2017 by Subz Used EndIf rather than EndFunc Link to comment Share on other sites More sharing options...
TheMysteries Posted February 19, 2017 Author Share Posted February 19, 2017 8 hours ago, Subz said: Try: CheckFileExists('C:\Windows2.txt') Func CheckFileExists($sString) For $i = 1 To 50 If FileExists($sString) = 1 Then Return 'Found' EndIf Sleep(100) Next Return 'Not Found' EndIf Nop doesn't work, Local $iCount = 1 While FileExists("C:\window2.txt") = 0 If $iCount = 50 Then $iCount = 0 ExitLoop EndIf $iCount += 1 WEnd If $iCount Then ConsoleWrite("Found") MouseClick("left",836, 318, 1) Else ConsoleWrite("NOT Found") EndIf With my line of script, it clicks 1x if statement = 'found' but after that it doesn't check if statement = 'found' or not 'found' so it just stops after 1 single click. Dunno how to make a loopback of that one Link to comment Share on other sites More sharing options...
Subz Posted February 19, 2017 Share Posted February 19, 2017 (edited) Maybe I'm reading it incorrectly, You have While FileExists("C:\Windows2.txt") = 0 keep looping , so If C:\Windows2.txt does exist it will exit the loop. I did forget to put in the MouseClick, I should have written: If CheckFileExists('C:\Windows2.txt') Then ConsoleWrite('Found' & @CRLF) MouseClick("left",836, 318, 1) Else ConsoleWrite('Not Found' & @CRLF) EndIf Func CheckFileExists($sString) For $i = 1 To 50 If FileExists($sString) = 1 Then Return True Sleep(100) Next Return False EndFunc If you didn't want to resuse the code as a function you could also just use: For $i = 1 To 50 If FileExists($sString) = 1 Then ConsoleWrite('Found' & @CRLF) MouseClick("left",836, 318, 1) ExitLoop EndIf Sleep(100) Next ConsoleWrite('Not Found' & @CRLF) Edited February 19, 2017 by Subz Used EndIf rather than EndFunc Link to comment Share on other sites More sharing options...
Subz Posted February 19, 2017 Share Posted February 19, 2017 Sorry just realised, I used EndIf rather than EndFunc in my posts above, have now updated. Link to comment Share on other sites More sharing options...
TheMysteries Posted February 19, 2017 Author Share Posted February 19, 2017 15 minutes ago, Subz said: Sorry just realised, I used EndIf rather than EndFunc in my posts above, have now updated. If CheckFileExists('C:\Windows2.txt') Then ConsoleWrite('Found' & @CRLF) MouseClick("left",836, 318, 1) Else ConsoleWrite('Not Found' & @CRLF) EndIf Func CheckFileExists($sString) For $i = 1 To 50 If FileExists($sString) = 1 Then Return True EndIf Sleep(100) Next Return False EndFunc It works but now the script have to read the output (found) If the script answers > Found then continue clicking (delay 2sec) untill output > not found Dunno if that is possible Link to comment Share on other sites More sharing options...
Subz Posted February 19, 2017 Share Posted February 19, 2017 Sorry don't really understand, can you explain what you want to happen preferably step by step? Do you mean: CheckFileExists('C:\Windows2.txt') Func CheckFileExists($sString) If FileExists($sString) = 1 Then While FileExists($sString) ConsoleWrite('Found' & @CRLF) MouseClick("left",836, 318, 1) Sleep(2000) WEnd EndIf ConsoleWrite('Not Found' & @CRLF) EndFunc Link to comment Share on other sites More sharing options...
TheMysteries Posted February 19, 2017 Author Share Posted February 19, 2017 4 minutes ago, Subz said: Sorry don't really understand, can you explain what you want to happen preferably step by step? Do you mean: CheckFileExists('C:\Windows2.txt') Func CheckFileExists($sString) If FileExists($sString) = 1 Then While FileExists($sString) ConsoleWrite('Found' & @CRLF) MouseClick("left",836, 318, 1) Sleep(2000) WEnd EndIf ConsoleWrite('Not Found' & @CRLF) EndFunc That's what I was looking for. Thanks for the help! 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