# Tips on making this better?

## Recommended Posts

First off Im a total noob. So please use KY.

```\$1 = 1

While \$1 = 1
Sleep(3000)
If WinActive("PROGRAM1", "") Then
Else
Exit
EndIf
\$1 = \$1 + 1
WEnd

\$StartX = 175
\$StartY = 200
\$i = 0
\$X = 0
\$Y = 0
\$Slots = 5;Rows you have open.
WinActivate("PROGRAM1", "")
Sleep(1000)
MouseClick("left", 500, 500, 2)
While \$i <= 30
MouseClick("right", \$StartX, \$StartY + \$Y, 2)
Sleep(1000)
Sleep(21000)
\$StartX = \$StartX + 32
\$X = \$X + 1
If \$X = 6 Then
\$Y = \$Y + 32
\$X = 0
\$StartX = 175
EndIf
If \$Y = \$Slots/32 Then ExitLoop
\$i = \$i + 1
If \$i = 40 Then Exitloop
If WinActive("PROGRAM1", "") Then
Else
Exit
EndIf
WEnd
EndFunc```

##### Share on other sites

First off Im a total noob. So please use KY.

```\$1 = 1

While \$1 = 1
Sleep(3000)
If WinActive("PROGRAM1", "") Then
Else
Exit
EndIf
\$1 = \$1 + 1
WEnd
\$StartX = 175
\$StartY = 200
\$i = 0
\$X = 0
\$Y = 0
\$Slots = 5;Rows you have open.
WinActivate("PROGRAM1", "")
Sleep(1000)
MouseClick("left", 500, 500, 2)
While \$i <= 30
MouseClick("right", \$StartX, \$StartY + \$Y, 2)
Sleep(1000)
Sleep(21000)
\$StartX = \$StartX + 32
\$X = \$X + 1
If \$X = 6 Then
\$Y = \$Y + 32
\$X = 0
\$StartX = 175
EndIf
If \$Y = \$Slots/32 Then ExitLoop
\$i = \$i + 1
If \$i = 40 Then Exitloop
If WinActive("PROGRAM1", "") Then
Else
Exit
EndIf
WEnd
EndFunc```
```; These 3 lines replace your loop as it will only
; execute once anyway, so you don't need a loop.
Sleep(3000)
WinActivate("Program1")

; All variables used in functions should be delcared locally

MouseClick("left", 500, 500, 2)
; If you're incrementing \$I by 1, just us a loop
for \$I = 0 to 29
; Normally, you don't use Exit in a function
if not WinActive("Program1") then Return
MouseClick("right", \$StartX, \$StartY + \$Y, 2)
Sleep(1000)
; This can't be right... 21 seconds?
Sleep(21000)
\$StartX += 32
\$X      += 1
If \$X = 6 Then
\$Y += 32
\$X  = 0
\$StartX = 175
EndIf
; The following line is useless. Y will never equal 0.16. Maybe you meant \$Slots * 32?
If \$Y = \$Slots/32 Then ExitLoop
; The following line is useless. You'll exit the loop before \$I gets to 40
If \$I = 40 Then Exitloop
next
EndFunc```

Auto3Lib: A library of over 1200 functions for AutoIt

## Create an account

Register a new account