Jump to content

I wrote this, but I can't figure it out


Recommended Posts

;
;
;
;
;
;
;
;
;
;
HotKeySet("{ESC}", "DoExit")
Func DoExit()
  Exit
EndFunc


;   scan for black color and then average them.
;   

Dim $sample
Dim $black[40000][2]
Dim $loop = 1
Dim $x_search = 765
Dim $y_search = 313
Dim $x_center = 0
Dim $y_center = 0

Do
    Do
        MouseMove ( $x_search, $y_search )
        $sample = PixelGetColor ( $x_search, $y_search )
        If $sample = 0  Then
        $black[$loop][0] =  $x_search
        $black[$loop][1] =  $y_search
        $loop = $loop + 1
        
            EndIf
        $y_search = $y_search - 1
    Until $y_search = 193
    $y_search = 313
    $x_search = $x_search + 1
Until $x_search = 886

$black[0] = $loop


Msgbox ( 0, "done!", 'there are ' & $loop & ' blacks' )

$loop = 1

Do
    $x_center = $x_center + $black[$loop][0]
    $loop = $loop +1

Until $loop > $black[0]

    $x_center = $x_center / $loop
    
    $loop = 1

Do
    $y_center = $y_center + $black[$loop][1]
    $loop = $loop +1

Until $loop > $black[0]

    $y_center = $y_center / $loop 

MsgBox ( 0, "title", 'x: ' & $x_center & 'y: ' & $y_center )



MouseMove ( $x_center, $y_center )

X = 765 ~ 886

Y = 193 ~ 313

It record the positions of color:black within the area defined

black[$loop][0] = x

black[$loop][1] = y

for some reason this would quit halfway.

Link to comment
Share on other sites

You declared the array $black with 2 dimensions, so every reference to it must have to subscripts. This, for example, is wrong:

$black[0] = $loopoÝ÷ Ù.¦ºi¹r槵«­¢+ØÀÌØí±­lÁulÁtôÀÌØí±½½

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...