ReDLiNe Posted October 27, 2009 Posted October 27, 2009 Hi,I'm new here and to AutoIt, just started coding yesterday. I've searched the forums but have been unable to find an answer to my dilemma.My dilemma is that I want to right click on a certain amount of different locations depending on the variable $items.Right now I have a set amount of items (4) that can be right clicked on. I want to be able to use the variable $items to select how many locations should be right clicked. Im confusing myself with this so here is a diagram of what I want to do.Also any sloppy code practice could that I could change, please let me know.Any help would be appreciatedHere is my code thus far:HotKeySet("+{F2}","onoff") HotKeySet("+{F3}","exitapp") Dim $click = False $delay = inputbox("", "What speed do you want the auto clicker to run at? *Please Note* speed goes in 1/1000 of a second increments, so five seconds would be 5000 milliseconds. WARNING: If you set the click speed too fast then there is a very good chance the clicker will miss items.") ;$items = inputbox("", "Number of items to be upgraded?") Sleep (500) MsgBox (0, "", "Running at delay of " & $delay & " milliseconds") MsgBox (0, "", "Push Shift+F2 to start/stop and Shift+F3 to exit.") Func onoff() If $click = False Then $click = True Else $click = False EndIf EndFunc Func exitapp() Exit EndFunc While True If $click = True Then MouseClick("right", 36, 55) sleep($delay) Mouseclick("right", 93, 55) sleep($delay) MouseClick("right", 151, 55) sleep($delay) MouseClick("right", 36, 110) sleep ($delay) EndIf WEnd
omikron48 Posted October 27, 2009 Posted October 27, 2009 You could try using a 2 dimensional array to store your click coordinates and a For...Next loop for the MouseClick(s) with (UBound($array) - 1) as the limit.
ReDLiNe Posted October 27, 2009 Author Posted October 27, 2009 You're a genius, I've been trying to delay learning about Arrays because they seem confusing but now that I've had a skim over the topics you mentioned it seems plausible. What result does giving UBound a value of -1 return?
Mison Posted October 27, 2009 Posted October 27, 2009 If you know exactly what size the array is, you don't have to use Ubound. Ubound returns the size of array dimensions. Hi ;)
omikron48 Posted October 27, 2009 Posted October 27, 2009 UBound returns the number of elements in an array. Your For...Next loop will loop from 0 to (UBound($array) - 1) since arrays are normally 0-based and the limits are included in the For...Next looping. So you have to deduct 1 from the UBound result, otherwise you will exceed the array boundary.
Mison Posted October 27, 2009 Posted October 27, 2009 Example: Dim $click [4][2] = [[36, 55],[93, 55],[151, 55],[36, 110]] For $i = 0 To 3 Sleep(1000) MouseClick("right", $click [$i][0], $click [$i][1]) Next Hi ;)
ReDLiNe Posted October 27, 2009 Author Posted October 27, 2009 Im really not grasping this Array concept, can you please explain to me why you're using [4][2] and the following syntax? Or point me in the direction of a thorough Array tutorial?
JohnOne Posted October 27, 2009 Posted October 27, 2009 (edited) Im really not grasping this Array concept, can you please explain to me why you're using [4][2] and the following syntax? Or point me in the direction of a thorough Array tutorial? There is 4 elements to that array (four sets of coordinates), with 2 dimensions (x and y) The paramaters after that are defining what those coordinates are(x,y) format. There is loads of stuff around the forum on arrays, I spent days reading them. Edited October 27, 2009 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
ReDLiNe Posted October 27, 2009 Author Posted October 27, 2009 (edited) My bad, I found out what the problem is! Thanks for all the help everyone! Edited October 27, 2009 by ReDLiNe
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