Jump to content

Recommended Posts

WinWaitActive("Diablo II")
$pos = WinGetPos ( "Diablo II" )
HotKeySet("n","dograb")
Func dograb()
    $low = 400
    $iPos = PixelSearch($pos[0],$pos[1],$pos[0]+800,$pos[1]+$low,0x948064)
    $search = 1
    if @error Then
        $search = 0
    EndIf
    while $search == 1
        $lowerC = PixelGetColor ( $iPos[0] , $iPos[1]+1 )
        $lowerC = Hex($lowerC, 6)
        if $lowerC == 0x948064  Then
            MouseClick("left",$iPos[0],$iPos[1],1,0)
            $search = 0
        Else
            $low = $iPos[1]-1
            $iPos = PixelSearch($pos[0],$pos[1],$pos[0]+800,$pos[1]+$low,0x948064)
            MsgBox(0,"",$low)
            if @error Then
                $search = 0
            EndIf
        EndIf
    WEnd
    
EndFunc
while 1
    Sleep(100)
WEnd

How can that EVER give me a

C:\Dokumente und Einstellungen\FFS\Desktop\AU3scripts\mylil.au3 (13) : ==> Subscript used with non-Array variable.:

$lowerC = PixelGetColor ( $iPos[0], $iPos[1]+1 )

$lowerC = PixelGetColor ( $iPos^ ERROR

Link to post
Share on other sites

You get that error when you try to use a subscript with non-array variable, just like the error says. It has nothing to do with @error being set.

getPixelColor is using iPos[] which is set with $iPos = PixelSearch(...)

if PixelSearch should Fail, @error will be set and though getPixelColor can not be run anymore, look at the code please...

Link to post
Share on other sites

Here we go, try this.

WinWaitActive("Diablo II")
$pos = WinGetPos ( "Diablo II" )
HotKeySet("n","dograb")
Func dograb()
    $low = 400
    $iPos = PixelSearch($pos[0],$pos[1],$pos[0]+800,$pos[1]+$low,0x948064)
    if @error then
        $search = 0
    else
        $search = 1
    endif
    while $search == 1
        $lowerC = PixelGetColor ( $iPos[0] , $iPos[1]+1 )
        $lowerC = Hex($lowerC, 6)
        if $lowerC == 0x948064  Then
            MouseClick("left",$iPos[0],$iPos[1],1,0)
            $search = 0
        Else
            $low = $iPos[1]-1
            $iPos = PixelSearch($pos[0],$pos[1],$pos[0]+800,$pos[1]+$low,0x948064)
            MsgBox(0,"",$low)
            if @error Then
                $search = 0
            EndIf
        EndIf
    WEnd
    
EndFunc
while 1
    Sleep(100)
WEnd
Link to post
Share on other sites

getPixelColor is using iPos[] which is set with $iPos = PixelSearch(...)

if PixelSearch should Fail, @error will be set and though getPixelColor can not be run anymore, look at the code please...

MsgBox clears @error

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...