Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 15:39

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



AutoIT Subscript used on non accessible Variable

Discussion on AutoIT Subscript used on non accessible Variable within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1

 
elite*gold: 10
Join Date: Sep 2013
Posts: 311
Received Thanks: 48
AutoIT Subscript used on non accessible Variable

Hey elitepvpers,

I tried to create a Script which will Move my Mouse Cursor to the location whenever the color 0xFB9303 is found, then it should wait for the color 0xFFCFC7 to appear, and after that it should click on it as fast as possible.

That seems to work but after a few seconds it crashes with the Crash Code:


Line 20 (File:"File Path, File Name")

Error: Subscript used on non-accessible variable


Heres the Code:

Code:
#RequireAdmin
HotKeySet("g", "start")
HotKeySet("h", "stop")

$WaitColor=0xFB9303
$ClickColor=0xFFCFC7

While 1
    Sleep(100)
WEnd

func stop()
    Exit
EndFunc

func start()
    while 1

      $productbar1 = PixelSearch(850,750,1050,800, $WaitColor,0)
      If Not @error Then
         MouseMove($productbar1[0],$productbar1[1], 1)
      EndIf
      $productbar2 = PixelSearch(850,750,1050,800, $ClickColor,0)
      If Not @error Then
         MouseMove($productbar1[0],$productbar1[1], 0)
         MouseClick("left", $productbar1[0], $productbar1[1]-5, 1, 0)
         Sleep(200)
      EndIf
    WEnd
EndFunc
ProofPros1 is offline  
Old 07/06/2020, 17:59   #2


 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,495
Received Thanks: 1,769
1. check whether the pixel was found with isArray($productbarX). It's better than @error

2.

Code:
$productbar2 = PixelSearch(850,750,1050,800, $ClickColor,0)
      If Not @error Then
         MouseMove($productbar1[0],$productbar1[1], 0)
         MouseClick("left", $productbar1[0], $productbar1[1]-5, 1, 0)
         Sleep(200)
Here, you write the result of PixelSearch in $productbar2 but you try to access $productbar1[0] and [1]. That causes the error
Moneypulation is offline  
Reply


Similar Threads Similar Threads
[AutoIT] Subscript used on non-accessible variable.
05/17/2020 - AutoIt - 4 Replies
Hi, I have a problem :/ Here is my code: #RequireAdmin #include "KDMemory.au3" Const $processName = "s4c.exe", $moduleName = $processName Const $baseOffset = 0x017293C0
Subscript used on non-accessible variable. Help?
11/18/2019 - AutoIt - 1 Replies
Delete please!! wrong thread.
Subscript used on non-accessible variable
10/08/2016 - AutoIt - 16 Replies
Hey, habe ein kleines Problem mit meinem Code hier. Es kommt immer die Fehlermeldung Subscript used on non-accessible variable. kann mir da einer helfen? For $i = 1 To 4 Step 1 Switch $i Case 1 $2coord = PixelSearch(871, 363, 997, 540, 0xCDEC82, 10, 1, $handle) ; Bereich A-B Case 2



All times are GMT +2. The time now is 15:39.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.