Jump to content

Array Help Please


Recommended Posts

Ok, so, here's my problem. I'm trying to call PixelSearch. By the documentation, it is supposed to return an array of two values, the x coordinate as [0] and the y coordinate as [1]. However, when I try to manipulate these values (i.e. store them into another variable), it gives me an error telling me the variable PixelSearch returned to is not an array. /wrists Here's the code and if anyone can point out my noob mistake, that'd be great. Thanks

#include <Misc.au3>

#include <Array.au3>

SplashTextOn ( "Reverse Engineer", "Welcome to Reverse Engineer. Sit back and let me do the work for you.", 400, 100, -1, -1, 0, "Ariel", 18)

Sleep ( 5000 )

SplashOff()

Dim $bit1Search[2]

Dim $bit2Search[2]

While 1

SplashTextOn ( "Reverse Engineer Setup", "Please click once on the center of the 2nd 35 bit.", 400, 100, -1, -1, 0, "Ariel", 16)

While 1

Sleep ( 100 )

If _IsPressed("01") Then

$pos = MouseGetPos()

ExitLoop

EndIf

WEnd

SplashOff()

$bit2x = $pos[0]

$bit2y = $pos[1]

Sleep ( 1000 )

$searchLx = $bit2x - 30

$searchTy = $bit2y - 30

$searchRx = $bit2x + 30

$searchBy = $bit2y + 30

$bit2Search = PixelSearch( $searchLx, $searchTy, $searchRx, $searchBy, 0x7CAAD0 )

Sleep (2000)

If Not @error Then

SplashTextOn ( "Reverse Engineer Setup", "Second bit found...continuing setup...", 400, 100, -1, -1, 0, "Ariel", 16 )

Sleep ( 3000 )

SplashOff()

Else

SplashTextOn ( "Reverse Engineer Setup", "Could not find the second bit...please wait...", 400, 100, -1, -1, 0, "Ariel", 16 )

EndIf

$bit2Loc1x = $bit2Search[0] - 19

$bit2Loc1y = $bit2Search[1] - 37

$bit2Loc2x = $bit2Search[0] + 44

$bit2Loc2y = $bit2Search[1] + 26

Send ( "{ENTER}" )

Sleep (100)

Send ( "Top Left " $bit2Loc1x ", " $bit2Loc1y "Bottom Right" $bit2Loc2x ", " $bit2Lox2y )

WEnd

Link to comment
Share on other sites

#include <Misc.au3>
#include <Array.au3>

SplashTextOn("Reverse Engineer", "Welcome to Reverse Engineer. Sit back and let me do the work for you.", 400, 100, -1, -1, 0, "Ariel", 18)
Sleep(2000)
SplashOff()


While 1

    SplashTextOn("Reverse Engineer Setup", "Please click once on the center of the 2nd 35 bit.", 400, 100, -1, -1, 0, "Ariel", 16)
    While 1
        Sleep(100)
        If _IsPressed("01") Then
            $pos = MouseGetPos()
            ExitLoop
        EndIf
    WEnd
    SplashOff()
    $bit2x = $pos[0]
    $bit2y = $pos[1]
    Sleep(1000)

    $searchLx = $bit2x - 30
    $searchTy = $bit2y - 30
    $searchRx = $bit2x + 30
    $searchBy = $bit2y + 30

    $bit2Search = PixelSearch($searchLx, $searchTy, $searchRx, $searchBy, 0x7CAAD0)

    ;Sleep(1000) there can be NO SLEPP HERE - when error checking

    If @error Then
        SplashTextOn("Reverse Engineer Setup", "Could not find the second bit...please wait...", 400, 100, -1, -1, 0, "Ariel", 16)
        Sleep(3000)
        SplashOff()
        Exit
    Else
        SplashTextOn("Reverse Engineer Setup", "Second bit found...continuing setup...", 400, 100, -1, -1, 0, "Ariel", 16)
        Sleep(3000)
        SplashOff()
    EndIf

    $bit2Loc1x = $bit2Search[0] - 19
    $bit2Loc1y = $bit2Search[1] - 37
    $bit2Loc2x = $bit2Search[0] + 44
    $bit2Loc2y = $bit2Search[1] + 26

    Send("{ENTER}")
    Sleep(100)
    Send("Top Left " & $bit2Loc1x & ", " & $bit2Loc1y & "Bottom Right" & $bit2Loc2x & ", " & $bit2Loc2y)


WEnd

I fixed the errors, this does not use color/mouse/cursor mode????

Overall, this may not be the best approach you might want to try using ControlCommand(), ControlSend() etc. because they are much more reliable. get the control info from the "Autoit window info tool" its in...

Start > All Programs > Autoit3

8)

NEWHeader1.png

Link to comment
Share on other sites

And the reason that I put that sleep command there was because I was wondering if I wasn't giving it enough time to finish checking the area for the pixel since it was giving me the same error as it is now. It is as if PixeLCheck isn't returning a value whatsoever. I even tried it EXACTLY as the documentation says with actual integers...nothing. It still tells me when it gets to the manipulation that the variable isn't an array. :-/

Link to comment
Share on other sites

#include <Misc.au3>
#include <Array.au3>

SplashTextOn("Reverse Engineer", "Welcome to Reverse Engineer. Sit back and let me do the work for you.", 400, 100, -1, -1, 0, "Ariel", 18)
Sleep(2000)
SplashOff()


While 1

    SplashTextOn("Reverse Engineer Setup", "Please click once on the center of the 2nd 35 bit.", 400, 100, -1, -1, 0, "Ariel", 16)
    While 1
        Sleep(100)
        If _IsPressed("01") Then
            $pos = MouseGetPos()
            ExitLoop
        EndIf
    WEnd
    SplashOff()
    $bit2x = $pos[0]
    $bit2y = $pos[1]
    Sleep(1000)

    $searchLx = $bit2x - 30
    $searchTy = $bit2y - 30
    $searchRx = $bit2x + 30
    $searchBy = $bit2y + 30
    
    Tester($searchLx, $searchTy, $searchRx, $searchBy, 0x7CAAD0)
    $bit2Search = PixelSearch($searchLx, $searchTy, $searchRx, $searchBy, 0x7CAAD0)
    
    ;Sleep(1000) there can be NO SLEPP HERE - when error checking

    If @error Then
        SplashTextOn("Reverse Engineer Setup", "Could not find the second bit...please wait...", 400, 100, -1, -1, 0, "Ariel", 16)
        Sleep(3000)
        SplashOff()
        Exit
    Else
        SplashTextOn("Reverse Engineer Setup", "Second bit found...continuing setup...", 400, 100, -1, -1, 0, "Ariel", 16)
        Sleep(3000)
        SplashOff()
    EndIf

    $bit2Loc1x = $bit2Search[0] - 19
    $bit2Loc1y = $bit2Search[1] - 37
    $bit2Loc2x = $bit2Search[0] + 44
    $bit2Loc2y = $bit2Search[1] + 26

    Send("{ENTER}")
    Sleep(100)
    Send("Top Left " & $bit2Loc1x & ", " & $bit2Loc1y & "Bottom Right" & $bit2Loc2x & ", " & $bit2Loc2y)


WEnd



Func Tester($left, $top, $right, $bottom, $color)
    
    ; try these with different numbers... see help
    Opt("MouseCoordMode", 1)        ;1=absolute, 0=relative, 2=client
    Opt("PixelCoordMode", 1)        ;1=absolute, 0=relative, 2=client
    
    $temp = GUICreate("looking for this color", 150, 100, 20, 20)
    GUISetBkColor($color)
    GUISetState()
    
    MouseMove($left, $top)
    MsgBox(0x0, "color", "Looking for The above color from the current mouse position", 3)
    
    MouseMove($right, $bottom)
    MsgBox(0x0, "color", "Looking for The above color to here", 3)
    
    $find = PixelSearch($left, $top, $right, $bottom, $color, 10, 50)
    If Not @error Then
        MsgBox(0x0, "color", "Found!!!!!")
    Else
        MsgBox(0x0, "color", "Color was NOT Found!!!!!")
    EndIf
    
    GUIDelete($temp)
EndFunc   ;==>Tester

8)

NEWHeader1.png

Link to comment
Share on other sites

Ok, just in case a Dev reads this, I went through the codes earlier in my folder. PixeLSearch.au3 contains nothing but the example code on the website. That's why it wasn't returning an array...there's no code! I knew I wasn't crazy! lol

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...