# hi i need help with moving mouse in a matrix 8x8

## Recommended Posts

Hi

-i have a matrix size 8 x 8...

what i want to do is:

i want my mouse to move from square to square from left to right and left clicking into them

any1 can help me?

PS

i came out with this code but doesnt work heh

\$i=1

While \$i <= 8

\$i=\$i+1

\$y=350

\$j=1

While \$j <= 8

\$x=923

MouseMove(\$x,\$y,2)

sleep(100)

MouseClick("left")

sleep(100)

MouseMove(579,334,2)

sleep(100)

MouseClick("left")

WEnd

\$y=\$y+32

WEnd

##### Share on other sites

I don't understand... a matrix? As in.. a grid in a window?

You are not being clear enough.

##### Share on other sites

```For \$y = 100 to 800
For \$x = 100 to 800
MouseClick('left', \$y + 10, \$x + 10)
Next
Next```

Assuming each "grid" square is 100 by 100 this will work when the top most square is in the top left corner.

EDIT: Looking in your code it doesn't look like you increment the X value anywhere, maybe that is your problem.

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

##### Share on other sites

Hi,

It's not cpu friendly, but here's a poor working example

```#include<GuiConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

Global \$Lbl[65][2], \$lX = 5, \$lY = 5, \$Cnt, \$Start

\$Gui = GUICreate("Matrix 8x8", 170, 200)
For \$i = 1 To 64
\$Lbl[\$i][0] = GUICtrlCreateLabel(\$i, \$lX, \$lY, 20, 20, \$SS_SUNKEN + \$SS_CENTER + \$BS_CENTER)
GUICtrlSetOnEvent(-1, "Clicked")
GUICtrlSetBkColor(-1, 0x0000ff)
GUICtrlSetColor(-1, 0xffff00)
GUICtrlSetFont(-1, 9, 700)
\$lX += 20
If Mod(\$i, 8) = 0 Then
\$lX = 5
\$lY += 20
EndIf
Next
\$Btn = GUICtrlCreateButton("Start", 55, 170, 60, 20)
GUICtrlSetOnEvent(-1, "Start")
GUISetOnEvent(\$GUI_EVENT_CLOSE, "Close", \$Gui)
GUISetState()

While 1
Sleep(100)
If \$Start = 1 Then Mouse()
WEnd

Func Clicked()
For \$i = 1 To 64
If @GUI_CtrlId = \$Lbl[\$i][0] Then
If \$Lbl[\$i][1] = 0 Then
GUICtrlSetBkColor(\$Lbl[\$i][0], 0xffff00)
GUICtrlSetColor(\$Lbl[\$i][0], 0x0000ff)
\$Lbl[\$i][1] = 1
Return
Else
GUICtrlSetBkColor(\$Lbl[\$i][0], 0x0000ff)
GUICtrlSetColor(\$Lbl[\$i][0], 0xffff00)
\$Lbl[\$i][1] = 0
Return
EndIf
EndIf
Next
EndFunc

Func Start()
If \$Start = 0 Then
\$Start = 1
Else
\$Start = 0
EndIf
EndFunc

Func Mouse()
\$Cnt += 1
Dim \$CGP = ControlGetPos(\$Gui, "", \$Lbl[\$Cnt][0])
If Not @error Then
If Not BitAnd(WinGetState(\$Gui, ""), 8) Then WinActivate(\$Gui, "")
MouseClick("left", \$CGP[0] + (\$CGP[2] / 2), \$CGP[1] + (\$CGP[3] / 2))
EndIf
If \$Cnt = 64 Then
\$Start = 0
\$Cnt = 0
Return
EndIf
EndFunc

Func Close()
Exit
EndFunc```

Cheers

## Create an account

Register a new account

×

• Wiki

• Back

• Git