Roy2010 Posted May 19, 2010 Share Posted May 19, 2010 ok i am trying to create a looping script, Do MouseClick( "left", 32,883, 1, 25) MouseClick( "left", 52,446, 1, 50) MouseClick( "left", 199,63, 1, 50) $i = $i + 1 Until $i =1 Do MouseClick( "left", 58,413, 1, 50) MouseClick( "left", 328,389, 1, 50) MouseClick( "left", 628,412, 1, 50) MouseClick( "left", 385,454, 1, 50) MouseClick( "left", 844,205, 1, 50) $j = $j + 1 Until $j =1 Do MouseClick( "left", 255,64, 1, 25) MouseClick( "left", 177,300, 1, 25) $k = $k + 1 Until $k =4 Do MouseClick( "left", 439,298, 1, 100) $o = $o + 1 Until $o =1 sleep(500) Do MouseClick( "left", 1418,7, 1, 100) $ccc = $ccc + 1 Until $ccc =1 While 1 Sleep(100) WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc is there any way i could say run this once it reaches the end, pause it for a while and then restart from the begining again? i have tried reading the help guide but i just cant figure it out, any help would be greatly appriciated Thanks Link to comment Share on other sites More sharing options...
Tvern Posted May 19, 2010 Share Posted May 19, 2010 This is one way to do it. ps. use code, or autoit tags when posting code. expandcollapse popupLocal $time = 5*60*1000 ;this is the time of miliseconds between function calls (5 minutes) you could also just use 300000, but this is more readable. While 1 _Main() Sleep($time) WEnd Func _Main() ;I put all your code in this function to make it easy to call it multiple times. You could also just place the original code directly in the while loop Do MouseClick("left", 32, 883, 1, 25) MouseClick("left", 52, 446, 1, 50) MouseClick("left", 199, 63, 1, 50) $i = $i + 1 Until $i = 1 Do MouseClick("left", 58, 413, 1, 50) MouseClick("left", 328, 389, 1, 50) MouseClick("left", 628, 412, 1, 50) MouseClick("left", 385, 454, 1, 50) MouseClick("left", 844, 205, 1, 50) $j = $j + 1 Until $j = 1 Do MouseClick("left", 255, 64, 1, 25) MouseClick("left", 177, 300, 1, 25) $k = $k + 1 Until $k = 4 Do MouseClick("left", 439, 298, 1, 100) $o = $o + 1 Until $o = 1 Sleep(500) Do MouseClick("left", 1418, 7, 1, 100) $ccc = $ccc + 1 Until $ccc = 1 EndFunc Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
Roy2010 Posted May 19, 2010 Author Share Posted May 19, 2010 This is one way to do it. ps. use code, or autoit tags when posting code. expandcollapse popupLocal $time = 5*60*1000 ;this is the time of miliseconds between function calls (5 minutes) you could also just use 300000, but this is more readable. While 1 _Main() Sleep($time) WEnd Func _Main() ;I put all your code in this function to make it easy to call it multiple times. You could also just place the original code directly in the while loop Do MouseClick("left", 32, 883, 1, 25) MouseClick("left", 52, 446, 1, 50) MouseClick("left", 199, 63, 1, 50) $i = $i + 1 Until $i = 1 Do MouseClick("left", 58, 413, 1, 50) MouseClick("left", 328, 389, 1, 50) MouseClick("left", 628, 412, 1, 50) MouseClick("left", 385, 454, 1, 50) MouseClick("left", 844, 205, 1, 50) $j = $j + 1 Until $j = 1 Do MouseClick("left", 255, 64, 1, 25) MouseClick("left", 177, 300, 1, 25) $k = $k + 1 Until $k = 4 Do MouseClick("left", 439, 298, 1, 100) $o = $o + 1 Until $o = 1 Sleep(500) Do MouseClick("left", 1418, 7, 1, 100) $ccc = $ccc + 1 Until $ccc = 1 EndFunc Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate i have tried running this, it does loop it so thanks for that but it runs it and then just loops the very first 4 clicks, am i doing somthing wrong? Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2010 Share Posted May 19, 2010 i have tried running this, it does loop it so thanks for that but it runs it and then just loops the very first 4 clicks, am i doing somthing wrong?I don't see where you declare your variables $i, $j etc. You need to reset these values to zero at the start of every repeat. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Roy2010 Posted May 19, 2010 Author Share Posted May 19, 2010 (edited) I don't see where you declare your variables $i, $j etc. You need to reset these values to zero at the start of every repeat. expandcollapse popupGlobal $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") $i = 0 $j = 0 $k = 0 $m = 0 $l = 0 $o = 0 $p = 0 $q = 0 $a = 0 $b = 0 $c = 0 $r = 0 $s = 0 $t = 0 $u = 0 $v = 0 $w = 0 $x = 0 $y = 0 $z = 0 $n = 0 $d = 0 $e = 0 $f = 0 $k = 0 $aa = 0 $bb = 0 $cc = 0 $dd = 0 $ee = 0 $ff = 0 $gg = 0 $hh = 0 $kk = 0 $ccc = 0 Local $time = 0.1*60*1000 While 1 _Main() Sleep($time) WEnd Func _Main() Do MouseClick("left", 32, 883, 1, 25) MouseClick("left", 52, 446, 1, 50) MouseClick("left", 199, 63, 1, 50) $i = $i + 1 Until $i = 1 Do MouseClick("left", 58, 413, 1, 50) MouseClick("left", 328, 389, 1, 50) MouseClick("left", 628, 412, 1, 50) MouseClick("left", 385, 454, 1, 50) MouseClick("left", 844, 205, 1, 50) $j = $j + 1 Until $j = 1 Do MouseClick("left", 255, 64, 1, 25) MouseClick("left", 177, 300, 1, 25) $k = $k + 1 Until $k = 4 Do MouseClick("left", 439, 298, 1, 100) $o = $o + 1 Until $o = 1 Sleep(500) Do MouseClick("left", 1418, 7, 1, 100) $ccc = $ccc + 1 Until $ccc = 1 EndFunc Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc Func Terminate() exit 0 EndFunc how do i reset the values at the end? Edited May 19, 2010 by Roy2010 Link to comment Share on other sites More sharing options...
99ojo Posted May 19, 2010 Share Posted May 19, 2010 (edited) Hi, Set / reset them to 0 in between the while loop before the call of _Main (). ;-)) Stefan Edited May 19, 2010 by 99ojo Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2010 Share Posted May 19, 2010 Maybe something like this: expandcollapse popupGlobal $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") Local $time = 0.1*60*1000 Local $i, $j, $k, $o, $ccc While 1 _ResetValues() _Main() Sleep($time) WEnd Func _ResetValues() $i = 0 $j = 0 $k = 0 $o = 0 $ccc = 0 EndFunc Func _Main() Do MouseClick("left", 32, 883, 1, 25) MouseClick("left", 52, 446, 1, 50) MouseClick("left", 199, 63, 1, 50) $i = $i + 1 Until $i = 1 Do MouseClick("left", 58, 413, 1, 50) MouseClick("left", 328, 389, 1, 50) MouseClick("left", 628, 412, 1, 50) MouseClick("left", 385, 454, 1, 50) MouseClick("left", 844, 205, 1, 50) $j = $j + 1 Until $j = 1 Do MouseClick("left", 255, 64, 1, 25) MouseClick("left", 177, 300, 1, 25) $k = $k + 1 Until $k = 4 Do MouseClick("left", 439, 298, 1, 100) $o = $o + 1 Until $o = 1 Sleep(500) Do MouseClick("left", 1418, 7, 1, 100) $ccc = $ccc + 1 Until $ccc = 1 EndFunc Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc Func Terminate() exit 0 EndFunc operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Roy2010 Posted May 19, 2010 Author Share Posted May 19, 2010 sorry i do not quite understand where or what i would type to do it, i am looking in the help section but i cant find a fucntion to reset, im sorry to be a pain Link to comment Share on other sites More sharing options...
Roy2010 Posted May 19, 2010 Author Share Posted May 19, 2010 Maybe something like this: expandcollapse popupGlobal $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") Local $time = 0.1*60*1000 Local $i, $j, $k, $o, $ccc While 1 _ResetValues() _Main() Sleep($time) WEnd Func _ResetValues() $i = 0 $j = 0 $k = 0 $o = 0 $ccc = 0 EndFunc Func _Main() Do MouseClick("left", 32, 883, 1, 25) MouseClick("left", 52, 446, 1, 50) MouseClick("left", 199, 63, 1, 50) $i = $i + 1 Until $i = 1 Do MouseClick("left", 58, 413, 1, 50) MouseClick("left", 328, 389, 1, 50) MouseClick("left", 628, 412, 1, 50) MouseClick("left", 385, 454, 1, 50) MouseClick("left", 844, 205, 1, 50) $j = $j + 1 Until $j = 1 Do MouseClick("left", 255, 64, 1, 25) MouseClick("left", 177, 300, 1, 25) $k = $k + 1 Until $k = 4 Do MouseClick("left", 439, 298, 1, 100) $o = $o + 1 Until $o = 1 Sleep(500) Do MouseClick("left", 1418, 7, 1, 100) $ccc = $ccc + 1 Until $ccc = 1 EndFunc Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc Func Terminate() exit 0 EndFunc Thankyou Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2010 Share Posted May 19, 2010 ThankyouNo problem. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
ShawnW Posted May 19, 2010 Share Posted May 19, 2010 umm if they start at 0 why even use Do... Until on some of those because they stop at 1 so only run once anyway. And why not use for if it does need repeating to avoid declaring or resetting variables anyway. Here this should do the same thing as above. expandcollapse popupGlobal $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") Local $time = 0.1*60*1000 While True _Main() Sleep($time) WEnd Func _Main() MouseClick("left", 32, 883, 1, 25) MouseClick("left", 52, 446, 1, 50) MouseClick("left", 199, 63, 1, 50) MouseClick("left", 58, 413, 1, 50) MouseClick("left", 328, 389, 1, 50) MouseClick("left", 628, 412, 1, 50) MouseClick("left", 385, 454, 1, 50) MouseClick("left", 844, 205, 1, 50) For $i = 1 To 4 MouseClick("left", 255, 64, 1, 25) MouseClick("left", 177, 300, 1, 25) Next MouseClick("left", 439, 298, 1, 100) Sleep(500) MouseClick("left", 1418, 7, 1, 100) EndFunc Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc Func Terminate() exit 0 EndFunc Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2010 Share Posted May 19, 2010 umm if they start at 0 why even use Do... Until on some of those because they stop at 1 so only run once anyway. And why not use for if it does need repeating to avoid declaring or resetting variables anyway.Makes perfect sense. operator64 ArrayWorkshop 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