Jump to content
Sign in to follow this  
dandymcgee

pixel search error

Recommended Posts

I'm trying to make my modified version of Wrench's diablo II town portal bot work. I keep getting this:

----------------------ERROR------------------------

AutoIt Error

Line 18 (File "C:\.....\......\Desktop\Town Portal.au3)

MouseClick("left", $Pix[0], $Pix[1])

MouseClick("left", $Pix^ ERROR

Error: Subscript used with non-Array variable.

----------------------ERROR------------------------

Here is the code:

HotKeySet("z", "MakeTP")
HotKeySet("{End}", "Close")

While 1
    Sleep(100)
WEnd

Func MakeTP()
    Sleep(100)
    Send("{F8}")
    MouseClick("right", 1, 1)
    Sleep(2000)
    $Pix = PixelSearch(374, 206, 658, 440, 0x6490E0)
    Sleep(1000)
    If @error Then
        MsgBox(0, "error", "cannot find tp")
    Else
        MouseClick("left", $Pix[0], $Pix[1])
    EndIf
    Sleep(10000)
EndFunc

Func Close()
    Exit
EndFunc

I'm using PixelSearch which is supposed to return two variables, but the error states it isn't array. I don't understand what is going on (obviously because I am posting this :whistle:). Any help is appreciated.

Dan

Edited by dandymcgee

Share this post


Link to post
Share on other sites

The Sleep(1000) right before the @error throws the @error off

Func MakeTP()
    Sleep(100)
    Send("{F8}")
    MouseClick("right", 1, 1)
    Sleep(2000)
    $Pix = PixelSearch(374, 206, 658, 440, 0x6490E0)
    Sleep(1000)
    If Not IsArray($Pix) Then
        MsgBox(0, "error", "cannot find tp")
    Else
        MouseClick("left", $Pix[0], $Pix[1])
    EndIf
    Sleep(10000)
EndFunc

Func Close()
    Exit
EndFunc


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

wow man, thanks for the instant reply. Now its just popping up my message box saying, "cannot find tp". I don't understand why it doesn't think that $Pix is an array... Please help.

Pix isn't an array because the color isn't found... Simple as that.

Make sure your PixelCoordMode matches the type of coords you gathered from your application.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

wow man, thanks for the instant reply. Now its just popping up my message box saying, "cannot find tp". I don't understand why it doesn't think that $Pix is an array... Please help.

whatever this line is looking for is not found, either wrong screen size, pictures changed or Blizzard put in blocking code which I don't think they did..

$Pix = PixelSearch(374, 206, 658, 440, 0x6490E0)

Share this post


Link to post
Share on other sites

should

$Pix = PixelSearch(374, 206, 658, 440, 0x6490E0)

be

$Pix = PixelSearch(374, 206, 658, 440, "0x6490E0")

I know that I always put the color in quotes. I'm not sure if it has to be though.

Share this post


Link to post
Share on other sites

should

$Pix = PixelSearch(374, 206, 658, 440, 0x6490E0)

be

$Pix = PixelSearch(374, 206, 658, 440, "0x6490E0")

I know that I always put the color in quotes. I'm not sure if it has to be though.

No

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

First i would like to say hi.. :P

i am making a script that finds the color red (or an other color, but that doesn't matter)

but i keep getting the same error.. but i dont have the sleep func.

it complains about the $dc[0] and $dc[1]

while 1 = 1
$loot = pixelsearch(1,1,1,1, 0xFFFFFF)
if not @error then
mouseclick('left', $loot[0], $loot[1], 3, 0)
endif
wend

EDIT: changed the code a bit

Edited by Kiesp

http://www.autoitscript.com/forum/index.php?showtopic=69911 <-- Best hacker ever :D

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  

×
×
  • Create New...