MrCheese Posted July 15, 2017 Posted July 15, 2017 (edited) double post Edited July 16, 2017 by MrCheese
MrCheese Posted July 15, 2017 Author Posted July 15, 2017 (edited) Hi All, Sorry for the title, not sure how to describe. Basically, I have a function, which I have trimmed down for this purpose. Basically, for when $i = X, and if the trigger $complete = yes is made and that if statement is completed, I want the function to exit for that $i. See: $term =8 Func Primary() For $i = 0 To UBound($term) - 1 ; checks if $completes = yes for $i in the past and exits loop and moves to the next $i WinActivate($term[$i]) Sleep(500) mouseclick("left",$SetX,$Sety) sleep(500) Local $finish = PixelGetColor(1100, 926) If $finish = $finishC Then $complete = "yes" Else $complete = "no" EndIf ; funtion does stuff here If $complete = "yes" Then WinActivate("Initial.xlsx") Sleep(1000) $oWorkbook2.Sheets($i + 1).Activate ; funtion does more stuff here EndIf WinActivate($term[$i]) Sleep(2000) MouseClick("left", $SetX, $Sety) Next EndFunc ;==>Primary How can I best log that for $i complete = "yes" previously? Thanks for your help. Edited July 16, 2017 by MrCheese
MrCheese Posted July 21, 2017 Author Posted July 21, 2017 Any thoughts? Let me know if I need to rephrase my question?
Trong Posted July 21, 2017 Posted July 21, 2017 (edited) TRY: Global $term = 8 ; ???????? Global $numYES = -1 Func Primary() ;~ Local $numYES For $i = 0 To UBound($term) - 1 ; checks if $completes = yes for $i in the past and exits loop and moves to the next $i If $i = $numYES Then ContinueLoop WinActivate($term[$i]) Sleep(500) MouseClick("left", $SetX, $Sety) Sleep(500) Local $finish = PixelGetColor(1100, 926) If $finish = $finishC Then $complete = "yes" Else $complete = "no" EndIf ; funtion does stuff here If $complete = "yes" Then WinActivate("Initial.xlsx") Sleep(1000) $oWorkbook2.Sheets($i + 1).Activate ; funtion does more stuff here $numYES=$i EndIf WinActivate($term[$i]) Sleep(2000) MouseClick("left", $SetX, $Sety) Next EndFunc ;==>Primary Edited July 21, 2017 by Trong -1 Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
MrCheese Posted July 21, 2017 Author Posted July 21, 2017 Thanks for your reply.. wouldn't I need to add something within this IF statement? If $complete = "yes" Then WinActivate("Initial.xlsx") Sleep(1000) $oWorkbook2.Sheets($i + 1).Activate ; funtion does more stuff here EndIf As that is the component that when entered causes the skip for $i in the next loop.
Trong Posted July 21, 2017 Posted July 21, 2017 YES: $numYES=$i (I fix and forget it!) Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
MrCheese Posted July 21, 2017 Author Posted July 21, 2017 Thanks, when I run this, it skips when $i = 0, as $term[$i] appears where $i = 1 and not $=0 does that make sense? If i remove, if $i = $numYES then continue loop, then the funtion behaves normally. Any thoughts? Func Primary() For $i = 0 To UBound($term) - 1 if $i = $numYES then ContinueLoop ToolTip("Opening Terminals, terminal: " & $i, 100, 4) WinActivate($term[$i]) WinWait($term[$i]) Sleep(100) MouseClick("left", $SetX, $Sety) Sleep(200) ToolTip("Colour Check", 100, 4) Local $finish = PixelGetColor(1100, 926)
Trong Posted July 21, 2017 Posted July 21, 2017 try change: Global $numYES to Global $numYES=-1 Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
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