Jump to content

Recommended Posts

Posted

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.

Posted Image

Also any sloppy code practice could that I could change, please let me know.

Any help would be appreciated

Here 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
Posted

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.

Posted

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?

Posted

If you know exactly what size the array is, you don't have to use Ubound. Ubound returns the size of array dimensions.

Hi ;)

Posted

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.

Posted

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?

Posted (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 by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...