# PixelSpiral Help

## Recommended Posts

I translated it from vb.

```Private Function FindColorSpiral(color, hdc, x, y, x1, y1, x2, y2 As Long) As POINTAPI
Dim direction, length, i As Integer
direction = 0: length = 1
If color = GetPixel(hdc, x, y) Then GoTo Done
Do
For i = 1 To length
Select Case direction
Case 0: y = y - 1
Case 1: x = x + 1
Case 2: y = y + 1
Case 3: x = x - 1
End Select
If color = GetPixel(hdc, x, y) Then GoTo Done
Next i
direction = (direction + 1) Mod 4
If (direction Mod 2) = 0 Then length = length + 1
Loop While Not ((x < x1) Or (y < y1) Or (x > x2) Or (y > y2))
If (color <> GetPixel(hdc, x, y)) Then x = -1: y = -1
Done:
FindColorSpiral.x = x
FindColorSpiral.y = y
End Function```

```Func PixelSpiral(\$Color, \$X, \$Y, \$X1, \$Y1, \$X2, \$Y2)
Local \$rx, \$ry, \$dir = 0, \$length = 1, \$i
Do
For \$i = 1 to \$length
Select
Case \$dir = 0
\$y -= 1
Case \$dir = 1
\$x += 1
Case \$dir = 2
\$y += 1
Case \$dir = 3
\$x -= 1
EndSelect
MouseMove(\$x, \$y, 0)
Sleep(2000)
;If \$Color = PixelGetColor(\$x, \$y) Then
;   Return (\$x & ", " & \$y)
;   ExitLoop 2
;EndIf
Next
\$dir = Mod(\$dir + 1, 4)
If Mod(\$dir, 2) = 0 Then \$length += 1
Until (\$x > \$x1) Or (\$y > \$y1) Or (\$x < \$x2) Or (\$y < \$y2)

If \$color <> PixelGetColor(\$x, \$y) Then
\$x = -1
\$y = -1
EndIf

Return (\$x & ", " & \$y)
EndFunc```

I try executing it with

`PixelSpiral(\$cWhite, 500, 500, 0, 0, 600, 600)`

and all I get is

```>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\Drew\My Documents\AutoIt\LSBOT\LSMod.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams
+>16:06:50 Starting AutoIt3Wrapper v.1.10.1.14  Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 2  CPU:X86  ANSI)
>Running AU3Check (1.54.14.0)  from:C:\Program Files\AutoIt3
+>16:06:50 AU3Check ended.rc:0
>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Drew\My Documents\AutoIt\LSBOT\LSMod.au3"
+>16:06:53 AutoIT3.exe ended.rc:0
+>16:06:54 AutoIt3Wrapper Finished
>Exit code: 0   Time: 3.748```

No mouse movement or anything.

##### Share on other sites

Fixed it

Used not for each statement in the until line

## Create an account

Register a new account

×

• Wiki

• Back

• Git