Jump to content

Recommended Posts

Posted

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

Posted (edited)

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.

Edited by greenmachine
Posted

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

Posted

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
Posted

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.

 

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
×
×
  • Create New...