Sign in to follow this  
Followers 0
kart442

Please don't LOL...Got to be an easier way

3 posts in this topic

Working on a game script (bot) 8x8 square with 7 colors.

It will take 10,000's of lines doing it this way and I'm sure it can be done a whole lot easier...RIGHT?

Heres what I've got. Thanks in advance for your help.

CODE

Do

If PixelGetColor(679, 708) = 0xF9F9F9 And PixelGetColor(679, 645) = 0xF9F9F9 And PixelGetColor(742, 582) = 0xF9F9F9 Then

MouseClick("left", 742, 582, 1, 50)

MouseClick("left", 679, 582, 1, 50)

EndIf

If PixelGetColor(679, 645) = 0xF9F9F9 And PixelGetColor(679, 582) = 0xF9F9F9 And PixelGetColor(742, 519) = 0xF9F9F9 Then

MouseClick("left", 742, 519, 1, 50)

MouseClick("left", 679, 519, 1, 50)

EndIf

If PixelGetColor(679, 582) = 0xF9F9F9 And PixelGetColor(679, 519) = 0xF9F9F9 And PixelGetColor(742, 456) = 0xF9F9F9 Then

MouseClick("left", 742, 456, 1, 50)

MouseClick("left", 679, 456, 1, 50)

EndIf

If PixelGetColor(679, 519) = 0xF9F9F9 And PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(742, 393) = 0xF9F9F9 Then

MouseClick("left", 742, 393, 1, 50)

MouseClick("left", 679, 393, 1, 50)

EndIf

If PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(742, 330) = 0xF9F9F9 Then

MouseClick("left", 742, 330, 1, 50)

MouseClick("left", 679, 330, 1, 50)

EndIf

If PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(679, 330) = 0xF9F9F9 And PixelGetColor(742, 267) = 0xF9F9F9 Then

MouseClick("left", 742, 267, 1, 50)

MouseClick("left", 679, 267, 1, 50)

EndIf

If PixelGetColor(679, 267) = 0xF9F9F9 And PixelGetColor(679, 330) = 0xF9F9F9 And PixelGetColor(742, 393) = 0xF9F9F9 Then

MouseClick("left", 742, 393, 1, 50)

MouseClick("left", 679, 393, 1, 50)

EndIf

If PixelGetColor(679, 330) = 0xF9F9F9 And PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(742, 456) = 0xF9F9F9 Then

MouseClick("left", 742, 456, 1, 50)

MouseClick("left", 679, 456, 1, 50)

EndIf

If PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(742, 519) = 0xF9F9F9 Then

MouseClick("left", 742, 519, 1, 50)

MouseClick("left", 679, 519, 1, 50)

EndIf

If PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(679, 519) = 0xF9F9F9 And PixelGetColor(742, 582) = 0xF9F9F9 Then

MouseClick("left", 742, 582, 1, 50)

MouseClick("left", 679, 582, 1, 50)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I don't see how this is searching an 8x8 pixel area.

You need to find a pattern in your code so that you can create a consistent loop or create a function and loop through an array of parameters.

Ugly way:

Dim $Array[5][5] = [[679, 742, 582, 708, 645], _
                    [679, 742, 519, 645, 582], _
                    [679, 742, 456, 582, 519], _
                    [679, 742, 393, 519, 456], _
                    [679, 742, 330, 456, 393]]


For $X = 0 to Ubound ($Array) - 1
    Search($Array[$X][0], $Array[$X][1], $Array[$X][2], $Array[$X][3], $Array[$X][4])
Next

;$V1 and $V2 always same?
Func Search($V1, $V2, $V3, $V4, $V5)
    If PixelGetColor($V1, $V4) = 0xF9F9F9 And PixelGetColor($V1, $V5) = 0xF9F9F9 And PixelGetColor($V2, $V3) = 0xF9F9F9 Then 
        MouseClick("left", $V2, $V3, 1, 50)
        MouseClick("left", $V1, $V3, 1, 50)
    EndIf
EndFunc

Are you just trying to verify that an 8x8 rectangle on the screen matches 0xF9F9F9??

Edited by weaponx

Share this post


Link to post
Share on other sites

Working on a game script (bot) 8x8 square with 7 colors.

It will take 10,000's of lines doing it this way and I'm sure it can be done a whole lot easier...RIGHT?

Heres what I've got. Thanks in advance for your help.

CODE

Do

If PixelGetColor(679, 708) = 0xF9F9F9 And PixelGetColor(679, 645) = 0xF9F9F9 And PixelGetColor(742, 582) = 0xF9F9F9 Then

MouseClick("left", 742, 582, 1, 50)

MouseClick("left", 679, 582, 1, 50)

EndIf

If PixelGetColor(679, 645) = 0xF9F9F9 And PixelGetColor(679, 582) = 0xF9F9F9 And PixelGetColor(742, 519) = 0xF9F9F9 Then

MouseClick("left", 742, 519, 1, 50)

MouseClick("left", 679, 519, 1, 50)

EndIf

If PixelGetColor(679, 582) = 0xF9F9F9 And PixelGetColor(679, 519) = 0xF9F9F9 And PixelGetColor(742, 456) = 0xF9F9F9 Then

MouseClick("left", 742, 456, 1, 50)

MouseClick("left", 679, 456, 1, 50)

EndIf

If PixelGetColor(679, 519) = 0xF9F9F9 And PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(742, 393) = 0xF9F9F9 Then

MouseClick("left", 742, 393, 1, 50)

MouseClick("left", 679, 393, 1, 50)

EndIf

If PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(742, 330) = 0xF9F9F9 Then

MouseClick("left", 742, 330, 1, 50)

MouseClick("left", 679, 330, 1, 50)

EndIf

If PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(679, 330) = 0xF9F9F9 And PixelGetColor(742, 267) = 0xF9F9F9 Then

MouseClick("left", 742, 267, 1, 50)

MouseClick("left", 679, 267, 1, 50)

EndIf

If PixelGetColor(679, 267) = 0xF9F9F9 And PixelGetColor(679, 330) = 0xF9F9F9 And PixelGetColor(742, 393) = 0xF9F9F9 Then

MouseClick("left", 742, 393, 1, 50)

MouseClick("left", 679, 393, 1, 50)

EndIf

If PixelGetColor(679, 330) = 0xF9F9F9 And PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(742, 456) = 0xF9F9F9 Then

MouseClick("left", 742, 456, 1, 50)

MouseClick("left", 679, 456, 1, 50)

EndIf

If PixelGetColor(679, 393) = 0xF9F9F9 And PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(742, 519) = 0xF9F9F9 Then

MouseClick("left", 742, 519, 1, 50)

MouseClick("left", 679, 519, 1, 50)

EndIf

If PixelGetColor(679, 456) = 0xF9F9F9 And PixelGetColor(679, 519) = 0xF9F9F9 And PixelGetColor(742, 582) = 0xF9F9F9 Then

MouseClick("left", 742, 582, 1, 50)

MouseClick("left", 679, 582, 1, 50)

If it were me doing it then I would create a text file containing all the coordinates e.g:

679, 708,679, 645,742, 582,742, 582,679, 582

679, 645,679, 582,742, 519,742, 519,679, 519

...

...

Then for the autoit script read these coordinates into an array.

You main program then just needs to loop through the array line by line using the coordinates read in from the array. (Use stringsplit to parse out the coordinates from each line) like so.

$csvFile = "X:\Path\yourfile.txt"
If FileExists($csvFile) Then
    If Not _FileReadToArray($csvFile, $csvArray) Then
        MsgBox(0,"Error","Error reading " & $csvFile)
    Else
        For $x = 1 To $csvArray[0] - 1
            $csvLine = $csvArray[$x]
            $csvLineArray = StringSplit($csvLine, Chr(44), 1)
            
            $x1 = $csvLineArray[1]
            $y1 = $csvLineArray[2]
            $x2 = $csvLineArray[3]
            $y2 = $csvLineArray[4]
            $x3 = $csvLineArray[5]
            $y3 = $csvLineArray[6]
            $x4 = $csvLineArray[7]
            $y4 = $csvLineArray[8]
            $x5 = $csvLineArray[9]
            $y5 = $csvLineArray[10]
            
            If PixelGetColor($x1, $y1) = 0xF9F9F9 And PixelGetColor($x2, $y2) = 0xF9F9F9 And PixelGetColor($x3, $y3) = 0xF9F9F9 Then
                MouseClick("left", $x4, $y4, 1, 50)
                MouseClick("left", $x5, $y5, 1, 50)
            EndIf
            
        Next
    EndIf
EndIf

This is just off the top of my head so is a bit rough and ready. I'm sure you can refine it.

Share this post


Link to post
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
Sign in to follow this  
Followers 0