Jump to content

PixelSearch acting oddly


Feri
 Share

Recommended Posts

I'm having a problem with pixelsearch on my runescape autoer program.

#include <misc.au3>
mousemove ( 399 , 329 , 0)
call ( "loldoit")
func quit ()
    Exit
EndFunc
func loldoit()
_mousetrap ()
$remainder = inputbox ( "Teletab Maker" , "Enter the amount of teletabs you want to make" , "28" )
if @error Then
    Exit
endif
$butlerruns = regread ( "HKEY_LOCAL_MACHINE/AUTOER" , "BUTLERRUNS")
if @error Then
    $butlerruns = 8
endif
$butlerruns = inputbox ( "Teletab Maker" , "Enter the amount of runs your butler has until next pay" , $butlerruns)
if @error Then
exit
EndIf
hotkeyset ( "{ESC}" , "quit")
while 1
While 1
    tooltip ( "Production in progress; There are "&$remainder& "teletabs remaining. Press ESC to quit the program at any time." ,1 ,1)
    $thisrun = 20
    $lectern = pixelsearch ( 599 , 684 , 606 , 415 , 0x302419 , 20) ;this is the pixelsearch command that doesn't work
    if  @error Then
        msgbox (14 , "Teletab Maker" , "Lectern is not found! lolololololololololololXD OWNED") ;it's supposed to display this if the lectern is not found
    endif
    mouseclick ( "left" , $lectern[0] , $lectern[1] , 1 , 0)
    sleep (2500)
    mouseclick ( "left" , 767, 292 , 1 ,0) ;click on tab icon
    sleep (2000)
    $remainder = $remainder-1
    tooltip ( "Production in progress; There are "&$remainder& "teletabs remaining. Press ESC to quit the program at any time." ,1 ,1)
    $thisrun = $thisrun-1
    if $thisrun = 0 Then
        ExitLoop
    endif
    wend
    if $remainder = 0 Then
        msgbox ( 14 , "Teletab Maker" , "Program has finished producing the desired amount of teletabs.")
    EndIf
    $butler = pixelsearch (490, 277 , 703 , 443, 0x5C130D , 25);search for butler
    if @error Then
        msgbox (14 , "Teletab Maker" , "An error occoured: Butler not found.")
    endif
    mouseclick ( "right" , $butler[0] , $butler[1] , 1 , 0) ;click on the butler
    sleep ( 500)
    $menucord_y = $butler[1]+50
    mouseclick ("left" , $butler[0] , $menucord_y , 1 , 0) ;click on bring from bank option
    sleep ( 1000)
    mouseclick ("left" , 257 , 654 , 1 , 0) ;click on "more..."
    sleep (1500)
    mouseclick ("left" , 254 , 604 , 1 , 0) ;click on "soft clay"
    sleep (1000)
    send ( "20") ;type in 20
    sleep (200)
    send ( "{ENTER}");press enter to send butler
    sleep (200)
    mouseclick ("left" , 1040 , 173, 1 , 0) ;click on run
    sleep (14000)
    mouseclick ("left" , 1045 , 167, 1 , 0) ;click on dialouge continue
    if $butlerruns = 0 Then
        mouseclick ( "left" , 254 , 604 , 1 , 0) ;click on "pay butler from bank"
        sleep (1500)
        $butlerruns = 9
    EndIf
    $butlerruns = $butlerruns-1
    regwrite ( "HKEY_LOCAL_MACHINE/AUTOER" , "BUTLERRUNS" , "REG_SZ" , $butlerruns)
    sleep (1000)
WEnd
endfunc

I set the command in question to look for a brown color, wich WAS on the screen at the time of execution. However when it came to the point where it had to click where the co-ordinates were given, the program closed with the following error:

C:\Documents and Settings\Timkó Tamás\Asztal\Teletabs.au3 (30) : ==> Subscript used with non-Array variable.:
mouseclick ( "left" , $lectern[0] , $lectern[1] , 1 , 0)
mouseclick ( "left" , $lectern^ ERROR
>Exit code: 1    Time: 5.678

So apparently, the co-ordinates weren't returned into $lectern[0] and $lectern[1] as they were supposed to, and as the help file says when it cannot find the pixel specified it sets @error to 1. However when i put in this:

$lectern = pixelsearch ( 599 , 684 , 606 , 415 , 0x302419 , 20)
    if  @error = 1 Then
        msgbox (14 , "Teletab Maker" , "Lectern is not found! lolololololololololololXD OWNED")
    endif

It didn't display any error message. So it didn't put in the variables, but it didn't set @error to 1 either. Also i am pretty sure the color it was told to look for was on the screen. So what might be the cause of this? And what should i do?

-Thanks in advance.

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