skilzrulz Posted October 7, 2004 Posted October 7, 2004 Is there anyway that I can like have a value, and have it randomly add or subtract the number, 1, 2, 3, 4, 5 (randomly pick out of that set) What I'm working with is like: Dim $x1, $y1, $x2, $y2 $x1 = 81 $y1 = 593 $x2 = 87 $y2 = 452 $speed = 5 MouseClickDrag("Left", ($x1 +- (1-5)), ($y1 +- (1-5)), ($x2 +- (1-5)), ($y2 +- (1-5)), ($speed +- (1-3))) Any way to make it add/subtract randomly, then make it add/subtract 1, 2, 3, 4, 5 at random? Also I would need it to loop, around, every (60,000MS +- (1,000MS-5,000MS)) If you can figure out this problem I am open to donateing for your help, AIM: o0oDakotao0o MSN: o69dakota69o@hotmail.com thanks!
CyberSlug Posted October 7, 2004 Posted October 7, 2004 (edited) This might work for the random part. I'll let you figure out the looping. ; General formula Random = Int(Rnd * Upperbound) + Lowerbound MouseClickDrag("Left", ($x1 + _Rand()), ($y1 + _Rand()), ($x2 + _Rand()), ($y2 + _Rand()), ($speed + _Rnd(1,3))) Func _Rand();hard coded 1 to 5 Return _Rnd(1, 5) EndFunc Func _Rnd($hi, $lo) If Random() < 0.5 Then Return Int(Random($hi)+$lo)) Else Return -Int(Random($hi)+$lo)) Endif EndFunc Edited October 7, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
scriptkitty Posted October 7, 2004 Posted October 7, 2004 Free, if you ever want to donate, Jon and the website can always use it. Dim $x1, $y1, $x2, $y2 $x1 = 81 $y1 = 593 $x2 = 87 $y2 = 452 $speed = 5 MouseClickDrag("Left", ($x1 +R5()), ($y1 +R5()), ($x2 +R5()), ($y2 +R5()), ($speed +R5())) func R5() $r=int(Random ( 1,6 )) If Random() < 0.5 Then $r = $r*(-1) return $r endfunc AutoIt3, the MACGYVER Pocket Knife for computers.
scriptkitty Posted October 7, 2004 Posted October 7, 2004 (edited) Dang Cyber ya beat me to it, but remember Random 1~5 is more like 1.00000 to 4.99999 the chance you ever see a 5 is um 1 in 100 million? I forgot the exact precision. Anyway that is why mine uses 1~6. Edited October 7, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
skilzrulz Posted October 7, 2004 Author Posted October 7, 2004 this is what i have Dim $x1, $y1, $x2, $x3, $speed $x1 = 81 $y1 = 593 $x2 = 87 $y2 = 452 $speed = 5 MouseClickDrag("Left", $x1 rnd(+,-) rnd(1,2,3,4,5), $y1 rnd(+,-) rnd(1,2,3,4,5), $x2 rnd(+,-) rnd(1,2,3,4,5), $y2 rnd(+,-) rnd(1,2,3,4,5), $speed rnd(+,-) rnd(1,2,3)) what's the function for random? AIM message would help
scriptkitty Posted October 7, 2004 Posted October 7, 2004 (edited) Random ( [[Min ,] Max] )Random (1,5) would give back a number like 2.03342so you want an int like this:Int(Random(1,5))That would never give you a 5, because Int just removes anything after the .So you actually want int(Random(1,6)) if you want 1~5For the second part, you just want a 50/50 chance of a negative, soIf Random() < 0.5 Then $r = $r*(-1) was my way of multiplying the result by -1 50% of the time.and my code does all your random +-(1 to 5) all in one:Dim $x1, $y1, $x2, $y2 $x1 = 81 $y1 = 593 $x2 = 87 $y2 = 452 $speed = 5 MouseClickDrag("Left", ($x1 +R5()), ($y1 +R5()), ($x2 +R5()), ($y2 +R5()), ($speed +R5())) ; I add the number that gets returned by R5(), when it is negative, adding a negative number is the same as subtracting. func R5() $r=int(Random ( 1,6 )); pick 1,2,3,4,or 5 If Random() < 0.5 Then $r = $r*(-1); 50% of the time make it negative return $r ; give the number back endfuncA quick tutorial showing that random(1,5) never gets a 5.$x="" for $i= 1 to 1000 $x=$x & "|"& int(Random(1,5)) if stringinstr($x,"5") then msgbox(1,"wow you got a 5",$x); not going to happen next msgbox(1,"",$x); here is 1000 random numbers seperated by | exithelp file:Random --------------------------------------------------------------------------------Generates a pseudo-random float-type number.Random ( [[Min ,]Max] ) ParametersMin [optional] The smallest number to be generated. The default is 0. Max [optional] The largest number to be generated. The default is 1. Return ValueSuccess: Returns a pseudo-random number between Min and Max. Failure: Returns numeric 1 and sets @error flag: 1 if argument is an array or non-numeric string 2 if Min > Max RemarksIf only one argument is provided, then it is interpreted to be the Max.The result will be a float in the range of Min to Max, including Min, but NOT including Max. RelatedInt, Round Example;Flip of coinIf Random() < 0.5 Then ; Returns a value between 0 and 1. $msg = "Heads. 50% Win"Else $msg = "Tails. 50% Loss"EndifMsgBox(0,"Coin toss", $msg );Roll of a diemsgBox(0,"Roll of die", "You rolled a " & Int(Random(6)+1)) Edited October 7, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
skilzrulz Posted October 7, 2004 Author Posted October 7, 2004 (edited) How would I get that to loop every 60 seconds, like this, "Drop/Drag -> 60,000MS+-5000MS(random again) -> drag/drop, etc, etc, etc Any ideas? thanks for being so helpful ;delay start Opt("MouseClickDelay", 60146) ;delay end Dim $x1, $y1, $x2, $y2 $x1 = 81 $y1 = 593 $x2 = 87 $y2 = 452 $speed = 5 MouseClickDrag("Left", ($x1 +R5()), ($y1 +R5()), ($x2 +R5()), ($y2 +R5()), ($speed +R5())) ; I add the number that gets returned by R5(), when it is negative, adding a negative number is the same as subtracting. func R5() $r=int(Random ( 1,6 )); pick 1,2,3,4,or 5 If Random() < 0.5 Then $r = $r*(-1); 50% of the time make it negative return $r; give the number back endfunc Edited October 7, 2004 by skilzrulz
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