Que Posted August 22, 2006 Share Posted August 22, 2006 I Have made a simple script for a game that I play which follows: ; Script Start While 1 MouseClick("right",250,350, 1, 2) MouseMove(250,350) $start = TimerInit() $diff = TimerDiff($start) While 1 If $time = 6 Then $coord = PixelSearch (250, 350, 950, 700, 0xF6F6F6, 40, 4) Else $coord = PixelSearch (250, 350, 950, 700, 0xEEEEEE, 55, 3) EndIf If UBound($coord)>1 Then MouseClick("right", $coord[0], $coord[1], 1, 3) Sleep(1000) MouseClick("right", 44, 230, 1, 5) sleep (200) ExitLoop Else Sleep(250) $diff = TimerDiff($start) If $diff > 30000 Then ExitLoop EndIf EndIf WEnd WEnd That has served its purpose for some time now but now I am looking to add antoher timer to the code. I would like another timer that initializes before the previous code and runs simultaneously until a certain point (5 minutes). All the while the previoud code is running in its loop. Once the first timer hits 5 minutes I Have this code to execute Mouseclick("left",360,957, 1, 2) Sleep(1000) Mouseclick("left",955,120, 1, 2) My problem is all version that i have written myself will run the first section of code fine but when it exits the loop it reinitiallizes the first timer back to 0 as well and therefore never executes the last peice of code. Any suggestions or places to look? Thanks in advance. Link to comment Share on other sites More sharing options...
Valuater Posted August 22, 2006 Share Posted August 22, 2006 2nd timer ; Script Start While 1 MouseClick("right",250,350, 1, 2) MouseMove(250,350) $start = TimerInit() $start2 = TimerInit() $diff = TimerDiff($start) While 1 If $time = 6 Then $coord = PixelSearch (250, 350, 950, 700, 0xF6F6F6, 40, 4) Else $coord = PixelSearch (250, 350, 950, 700, 0xEEEEEE, 55, 3) EndIf If UBound($coord)>1 Then MouseClick("right", $coord[0], $coord[1], 1, 3) Sleep(1000) MouseClick("right", 44, 230, 1, 5) sleep (200) ExitLoop Else Sleep(250) $diff2 = TimerDiff($start2) ; if diff2 ... blah $diff = TimerDiff($start) If $diff > 30000 Then ExitLoop EndIf EndIf WEnd WEnd 8) Link to comment Share on other sites More sharing options...
Que Posted August 22, 2006 Author Share Posted August 22, 2006 2nd timer ; Script Start While 1 MouseClick("right",250,350, 1, 2) MouseMove(250,350) $start = TimerInit() $start2 = TimerInit() $diff = TimerDiff($start) While 1 If $time = 6 Then $coord = PixelSearch (250, 350, 950, 700, 0xF6F6F6, 40, 4) Else $coord = PixelSearch (250, 350, 950, 700, 0xEEEEEE, 55, 3) EndIf If UBound($coord)>1 Then MouseClick("right", $coord[0], $coord[1], 1, 3) Sleep(1000) MouseClick("right", 44, 230, 1, 5) sleep (200) ExitLoop Else Sleep(250) $diff2 = TimerDiff($start2) ; if diff2 ... blah $diff = TimerDiff($start) If $diff > 30000 Then ExitLoop EndIf EndIf WEnd WEnd 8) Thank you for the quick reply I am implementing this now but to make sure I understand this correct then I should add the new code on the line that you have written ; if diff2 ....blah blah. Link to comment Share on other sites More sharing options...
Valuater Posted August 22, 2006 Share Posted August 22, 2006 i cant answer that because i dont really understand your whole process/script and its needs... but you can try puting info on that line 8) Link to comment Share on other sites More sharing options...
Que Posted August 22, 2006 Author Share Posted August 22, 2006 (edited) Ok I have changed the code and added the new lines for the second timer and now Im getting an error on line 63 which is Wend not associated with a while. Here is the code: ; Script Start While 1 MouseClick("right",250,350, 1, 2) $start = TimerInit() $start2 = TimerInit() $diff = TimerDiff($start) While 1 If $time = 6 Then $coord = PixelSearch (250, 350, 950, 700, 0xF6F6F6, 40, 4) Else $coord = PixelSearch (250, 350, 950, 700, 0xEEEEEE, 55, 3) EndIf If UBound($coord)>1 Then MouseClick("right", $coord[0], $coord[1], 1, 3) Sleep(1000) MouseClick("right", 44, 230, 1, 5) sleep (200) ExitLoop Else Sleep(250) $diff2 = TimerDiff($start2) If $diff2 >65000 Then Mouseclick("left",360,957, 1, 2) Sleep(1000) Mouseclick("left",955,120, 1, 2) $diff = TimerDiff($start) If $diff > 30000 Then exitloop EndIf EndIf WEnd WEnd Not sure why this is happening as all my while statements match up with a wend and I cant find any extras. Any directions to go in? Thanks. Edited August 22, 2006 by Que Link to comment Share on other sites More sharing options...
Valuater Posted August 22, 2006 Share Posted August 22, 2006 cleaned expandcollapse popup; Script Start $time = "" ; for testing $start2 = TimerInit() While 1 MouseClick("right",250,350, 1, 2) MouseMove(250,350) $start = TimerInit() $diff = TimerDiff($start) While 1 If $time = 6 Then $coord = PixelSearch (250, 350, 950, 700, 0xF6F6F6, 40, 4) Else $coord = PixelSearch (250, 350, 950, 700, 0xEEEEEE, 55, 3) EndIf ; 5, 300 - 1024, 560 can be changed if you want to search a wider area. ; Not recommended though since you can just adjust your view to fit all ; the water in that space. The bigger the area, the less likely it is to ; detect it. ; If the splash isn't getting detected then change the hex colour to ; something a bit closer. Top one is day, bottom is night. If UBound($coord)>1 Then MouseClick("right", $coord[0], $coord[1], 1, 3) Sleep(1000) MouseClick("right", 44, 230, 1, 5) sleep (200) ExitLoop Else Sleep(250) $diff2 = TimerDiff($start2) If $diff2 >65000 Then Mouseclick("left",360,957, 1, 2) Sleep(1000) Mouseclick("left",955,120, 1, 2) $start2 = TimerInit() ; reset timer EndIf If $diff > 30000 Then exitloop EndIf WEnd WEnd 8)_ Link to comment Share on other sites More sharing options...
Helge Posted August 22, 2006 Share Posted August 22, 2006 There was a missing EndIf and not a missing WEnd. Btw, you don't need two timers since you're starting them basically at the same time.; Script Start While 1 MouseClick("right", 250, 350, 1, 2) $start = TimerInit() $start2 = TimerInit() $diff = TimerDiff($start) While 1 If $time = 6 Then $coord = PixelSearch(250, 350, 950, 700, 0xF6F6F6, 40, 4) Else $coord = PixelSearch(250, 350, 950, 700, 0xEEEEEE, 55, 3) EndIf If UBound($coord) > 1 Then MouseClick("right", $coord[0], $coord[1], 1, 3) Sleep(1000) MouseClick("right", 44, 230, 1, 5) Sleep(200) ExitLoop Else Sleep(250) $diff2 = TimerDiff($start2) If $diff2 > 65000 Then MouseClick("left", 360, 957, 1, 2) Sleep(1000) MouseClick("left", 955, 120, 1, 2) If $diff > 30000 Then ExitLoop EndIf EndIf EndIf WEnd WEnd Link to comment Share on other sites More sharing options...
Que Posted August 22, 2006 Author Share Posted August 22, 2006 THANK YOU THANK YOU Heres the final version of that portion of script and it works flawlessly now. I cleaned it up a bit and had to move the first timer out of the first loop. expandcollapse popup; Script Start While 1 $start2 = TimerInit() While 1 MouseClick("right",250,350, 1, 2) $start = TimerInit() While 1 If $time = 6 Then $coord = PixelSearch (250, 350, 950, 700, 0xF6F6F6, 40, 4) Else $coord = PixelSearch (250, 350, 950, 700, 0xEEEEEE, 55, 3) EndIf If UBound($coord)>1 Then MouseClick("right", $coord[0], $coord[1], 1, 3) Sleep(1000) MouseClick("right", 44, 230, 1, 5) sleep (200) ExitLoop Else sleep (200) $diff2 = TimerDiff($start2) If $diff2 >= 300000 Then Mouseclick("left",360,957, 1, 2) Sleep(1000) Mouseclick("left",955,120, 1, 2) sleep (6000) $start2 = TimerInit() Exitloop EndIf $diff = TimerDiff($start) If $diff > 33000 Then ExitLoop EndIf EndIf WEnd WEnd WEnd Link to comment Share on other sites More sharing options...
Que Posted August 22, 2006 Author Share Posted August 22, 2006 Helge - not sure how I would do it without two timers as one of the timers is constazntly restting itself and starting over while the other runs. There will be times when one timer is in the middle of expiring and the other at the end. Any thoughts or corrections are appreciated. Link to comment Share on other sites More sharing options...
Helge Posted August 22, 2006 Share Posted August 22, 2006 Crapily crap. I didn't see that TimerInit inside that bunch of code It's showed before that I shouldn't post after midnight, and it's like 6 AM here now.. Good night.. 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