Jump to content

Subscript used on non-accesible variable


Recommended Posts

Hello i was editing a little program for autoit, this is the autoit program:

#include <ImageSearch.au3>
#include <GDIPlus.au3>


While 1
$fileA = @ScriptDir & "\imagenes\link.bmp"

_GDIPlus_Startup()

$hImageA =_GDIPlus_ImageLoadFromFile($fileA)
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)

$x = 0
$y = 0

$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0)
If $result > 0 Then
 MouseMove($x, $y)
 MouseClick("left") 
    Send ("{DELETE}") 
 Send("") 
 Send("{ENTER}") 
 ExitLoop
 EndIf
 sleep(300)
WEnd


Sleep(30000) 

$fileA = @ScriptDir & "\imagenes\BotonPubli.bmp"

_GDIPlus_Startup()

$hImageA =_GDIPlus_ImageLoadFromFile($fileA)
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)

$x = 0
$y = 0

$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;
If $result > 0 Then
 MouseMove($x, $y)
 MouseClick("left")

EndIf

Sleep(15000) 
$fileA = @ScriptDir & "\imagenes\BotonAbajo.bmp"

_GDIPlus_Startup()

$hImageA =_GDIPlus_ImageLoadFromFile($fileA)
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)

$x = 0
$y = 0

$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0)
If $result > 0 Then
 MouseMove($x, $y)
 MouseClick("right") 
EndIf
While 1
$fileA = @ScriptDir & "\imagenes\Cebolla.bmp"

_GDIPlus_Startup()

$hImageA =_GDIPlus_ImageLoadFromFile($fileA)
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)

$x = 0
$y = 0

$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0)
If $result > 0 Then
 MouseMove($x, $y)
 Sleep(30000)
 MouseClick("left") 
 Send("{DOWN}")
 Send("{ENTER}")
 ExitLoop
 EndIf
 sleep(300)
WEnd
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()

I try to change the last part to:

$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0)
If $result > 0 Then
 MouseMove($x, $y)
 MouseClick("left") ;Clika con boton izquierdo
EndIf
WEnd
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()

But still i get all the time Error when i run the script..: Subscript used on non-accesible variable Line 11. What i'm doing wrong?

Edited by SoyArcano
Link to comment
Share on other sites

The error is in ImageSearch.au3. This topic has been created so many times, the question has been asked so many times, and it has been answered so many times. The ImageSearch.au3 UDF should have proper error checking throw into it and re-released or something.

Throw in If (@Error) in the ImageSearch function after it does the DLLCall to the ImageSearchDLL.dll or check that $result is an array (IsArray($result))

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