# Converting Coords into an Array?

## Recommended Posts

Hey,

I have a grid of: 6x10 and I am looking to try and get an easier way to move to each grid "cube"

```AniMouseClick(\$CubeOneX + (\$CubeSize * 0), \$CubeOneY + (\$CubeSize * 0), 0)  ; Top Right
AniMouseClick(\$CubeOneX + (\$CubeSize * 0), \$CubeOneY + (\$CubeSize * 5), 0)  ; Bottom Right
AniMouseClick(\$CubeOneX - (\$CubeSize * 9), \$CubeOneY + (\$CubeSize * 5), 0)  ; Bottom Left
AniMouseClick(\$CubeOneX - (\$CubeSize * 9), \$CubeOneY + (\$CubeSize * 0), 0)  ; Top Left```

It would be good if I could do:

```AniMouseClick(10, 1, 1) ; Top Right
AniMouseClick(10, 6, 1) ; Bottom Right
AniMouseClick(1, 6, 1) ; Bottom Left
AniMouseClick(1, 1, 1) ; Top Left```

Does anyone know how I can achieve this?

Edited by XxXGoD

##### Share on other sites

set up a 2d array like so

`Dim aCoords[5][2] = [ [10, 10], [15, 10], [20, 10], [25, 10], [30, 10]  ] ; [x coord, y coord]`

##### Share on other sites

```#include <Array.au3>

\$iSize = 20

\$iMidPoint = \$iSize/2
\$iMaxX = 6
\$iMaxY = 10
Dim \$aGrid[\$iMaxX][\$iMaxY]
\$X = \$iMidPoint
For \$i = 0 To UBound ( \$aGrid ) - 1
\$Y = \$iMidPoint
For \$j = 0 To UBound ( \$aGrid, 2 ) - 1
\$aGrid[\$i][\$j] = \$X & "," & \$Y
\$Y = \$Y  + \$iSize
Next
\$X = \$X + \$iSize
Next

_ArrayDisplay ( \$aGrid )

; Click 0,0:
\$XYCoord = \$aGrid[0][0]
\$aXYCoord = StringSplit ( \$XYCoord, "," )
\$sXCoord = \$aXYCoord[1]
\$sYCoord = \$aXYCoord[2]
MsgBox ( 4096, "click pos", "xcoord=" & \$sXCoord & " ycoord=" & \$sYCoord )```

example of getting where to click for 0,0( bottom left box )...but you can sub in any coord, like 3,8: \$aGrid[3][8]

replace \$iSize = 20 with actual pixel size of squares

oh, and these are coords relative to the starting point of the grid (bottom left)...that's important

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.

## 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

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...