Jump to content

Subscript used on non-accessible variable.


Recommended Posts

Hi guys im having a problem in to my code so first thing the code is working when i open and run it into Scite im using image search so after i compiled my code and put my compiled code into other files i mean like i move it into desktop and run the code then there i will have the problem Autoit Error Line 15 Error:Subscript used on non-accesible variabble. i will show some my code  i cant figure out what is the problem even its working 101% when not compiled and run in folder .

#include <ImageSearch.au3>

    HotKeySet("{F1}", "myExit")
    Global $Loc1 = 0
    Global $x = 0
    Global $y = 0



while 1

   Loc1()


   WEnd

Func Loc1()

    Do
        $Loc1 = _imagesearcharea("Loc1Spt.png", 1, 0, 0,764, 55, $x, $y, 150)
        If $Loc1 = 1 Then
            Sleep(2000)
        ElseIf $Loc1 = 0 Then
            Sleep(500)
            MsgBox($Loc1,"","WAITING",1)
            Sleep(1000)
        EndIf
     Until $Loc1 = 1
     MsgBox(0,"FOUND","")
 EndFunc

 

Link to comment
Share on other sites

after testing and trying and looking for a problem i guest my problem is on image search and i already fix but another problem comes after editing my image search  adding     ; Error checking goes here If (IsArray($result) = False) Then Return 0 after DllCall problem fix i didnt get the error message saying that varible use without being declaired and i can use it like i move the compiled files into desktop and no error but another problem image search cant find the picture even the picture is there still telling waiting waiting and cant even find i wish some one help me here ????

Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0)
    ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
    if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
If IsString($findImage) Then
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP)
Else
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findImage,"ptr",$HBMP)
EndIf
    
    ; Error checking goes here
    If (IsArray($result) = False) Then Return 0
    ; If error exit
    if $result[0]="0" then return 0

    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0],"|")

   $x=Int(Number($array[2]))
   $y=Int(Number($array[3]))
   if $resultPosition=1 then
      $x=$x + Int(Number($array[4])/2)
      $y=$y + Int(Number($array[5])/2)
   endif
   return 1
EndFunc

 

Link to comment
Share on other sites

is there any way to fix Image search causeimage is found when both compile code and image is on the same folder but when i move or say i cut the compile code then put in desktop or any new folder alone image search return 0 cant find whats inside the code can any one help me ??????? 

 

Link to comment
Share on other sites

Just now, Nine said:

make sure you use full path for the .dll

If you move .exe to another folder, then it won't find the dll anymore 

how can i do that can you give me example on what should i do ?

 

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