Jump to content

Click List of Coords Randomly [Should be easy]


Recommended Posts

First let me say I am used to programming in Java but learning AutoIt so far has been a blast!

My Problem:

I have a list of coordinates, for argument sake lets say they are as follows:

Coord1 is  (100,100)

Coord2 is (200,200)

Coord3 is  (300,300)

  • I want to click all three of these coordinates with Mouseclick func.
  • I want the order of the clicks to be random...For example

First loop through it clicks: 1, 3, 2

Second loop through it clicks: 3, 1, 2

Third loop through it clicks: 2, 1, 3

and so on and so on.

 

Any leads, hints, tips, and pointers would be very helpful. Thank you in advance!

 

 

Link to comment
Share on other sites

#include <Array.au3>
Local $a[3][2] = [[100,100],[200,200],[300,300]]

While True
    $aTemp = $a
    While UBound($aTemp)
        $iRandom = Random(0,UBound($aTemp)-1,1)
        ConsoleWrite($iRandom & @CRLF)
        MouseClick("left",$aTemp[$iRandom][0],$aTemp[$iRandom][1])
        _ArrayDelete($aTemp,$iRandom)
    WEnd
    MsgBox(1,1,1)
WEnd

 

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • Moderators

As you progress with AutoIt, I would suggest moving soon from inconsistent methods like mouseclicks to using controlclick. That way, it doesn't matter if the window is visible or not, or where on the screen the control is.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@UncleLouie909

In short, there are several ways to automate a window.

You can do it via mouse clicks, which is the "immediate" and easiest method, but, not the best one, since, if the window moves, or another window appears, or any other message which "interferes" with you script, your script will fail.

To avoid all of these, there are Control* functions ( you can take a look in the Help file about those ), which let you use directly the titles, handles, classnames... of the windows/controls you are automating, making things "easier", since, even if your window moves, or lost focus, you can set in with Win* functions, to let your script work at its best.

Then, to work with controls, there are a tons of functions which will let you click, send, set data... almost every control in your window.

To get the titles, handles, and all of the information needed to automate your windows/controls, there's a tool which comes with AutoIt, called AutoItWindowInfoTool; open it, and have fun!

And then, in some other special cases, when you are not able to use Control* functions to automate you windows, there is another one "tool" which is called UIAutomation. Take a look in the forum, especially the post of @junkew, which made a very good explanation of UIAutomation, and when it should be used.

Hope I made you things a little bit clearer now :)

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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