Jump to content
Sign in to follow this  
Kidney

AutoIT non-array variable?

Recommended Posts

Kidney

Error i get when running my code:

"Line 854 (File "C:\Users\Jon\Documents\PixelClick.exe"):

Error: Subscript use with non-Array Variable."

Func BuyTwo()
MouseClick("left", 435, 18, 1, 0)
Sleep(100)
$Buy = PixelSearch( 1410, 450, 1540, 495, 0xF0F0F0)
MouseClick( "Left", $Buy[0]+5, $Buy[1]+5, 1, 0)
Sleep(100)
MouseClick("left", 695, 18, 1, 0)
Sleep(100)
$Buy = PixelSearch( 1410, 450, 1540, 495, 0xF0F0F0)
MouseClick( "Left", $Buy[0]+5, $Buy[1]+5, 1, 0)
EndFunc

there is other code but this is where i get the error. any ideas what im doing wrong??

Share this post


Link to post
Share on other sites
water

In your case $Buy is no array. Check for errors after each PixelSearch.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kidney

In your case $Buy is no array. Check for errors after each PixelSearch.

well the thing is, it works half the time and the other half it doesnt. if it doesnt find a pixel with the specific color, will it give me that error??

Share this post


Link to post
Share on other sites
Shaggi

well the thing is, it works half the time and the other half it doesnt. if it doesnt find a pixel with the specific color, will it give me that error??

Yes, it sets @error and doesn't return an array, when no pixel is found.

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Share this post


Link to post
Share on other sites
water

I suggest you read the help file. All info can be found there.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kidney

alright i got it working. just added a couple of error proofing steps that probably make it look a little sloppy but it gets the job done.

final code:

Func BuyTwo()
    $Buy = 0
    MouseClick("left", 435, 18, 1, 0) ;Tab 1
    Sleep(100)
    $Buy = PixelSearch( 1410, 450, 1540, 495, 0xF0F0F0, 2) ;Look for the buy button
    Sleep(100)
    While $Buy = 0 ;Re-search for the buy button if not found the first time
        $Buy = PixelSearch( 1410, 450, 1540, 495, 0xF0F0F0, 2)
        Sleep(100)
    WEnd
    MouseClick( "Left", $Buy[0]+5, $Buy[1]+5, 1, 0) ;Click the buy button
    $Buy = 0
    Sleep(100)
    MouseClick("left", 695, 18, 1, 0) ;Tab 2
    Sleep(100)
    $Buy = PixelSearch( 1410, 450, 1540, 495, 0xF0F0F0, 2) ;Look for the buy button
    Sleep(100)
    While $Buy = 0 ;Re-search for the buy button if not found the first time
        $Buy = PixelSearch( 1410, 450, 1540, 495, 0xF0F0F0, 2)
        Sleep(100)
    WEnd
    MouseClick( "Left", $Buy[0]+5, $Buy[1]+5, 1, 0) ;Click the buy  button
    Sleep(100)
    MouseClick("left", 200, 18, 1, 0) ;Home Tab
    MouseMove(875, 850, 0) ;Move closer to "I have them all"
EndFunc

Share this post


Link to post
Share on other sites
Ramzes

It looks like a bot.


Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]

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  

  • Similar Content

    • vati1011
      By vati1011
      Hey, guys.
      Currently, I'm using Opencv UDF and i'm  encountering issues with DLLOPEN(). it is failing and returning -1
      But, I cannot figure out why it is failing.
      I need help from people.
      I'm running windows 10 32bit.
      This's my code.
      #RequireAdmin $fileopen = DllOpen("opencv_core2413.dll") MsgBox(0,"Result",$fileopen) Example.au3opencv_core2413.dll
    • Skeletor
      By Skeletor
      Hi Virtual People,
      My array works perfectly fine. However, what is the best practice if the line in the array doesn't have the correct amount of columns and if I can add a placeholder?

       
      For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") Next  
    • MrCheese
      By MrCheese
      hi all,
      reviewing the forum, this thread is applicable: 
       
       
      I wanted to know if there is now a better way to do this?
      In essence, I load a tab delimited txt file into an array (works well). I used tab, as some fields in the original csv contains commas.
      However, I needed autoit to manipulate this array, and output it as a csv.
      IF my array contains items with a comma, without double quotes around the field, then how best do I get a csv out of this?
      My current workaround is to filewritefromarray tab delimited, then open it in excel and save as a csv. I will need to check this to see how the address fields behave that contain a comma.
       
      Any thoughts would be appreciated.
       
    • Skeletor
      By Skeletor
      Hi All,

      I would like to know how you would take a FileLineRead and insert it into an array which then inserts it into Excel?
      One thing to know is the files content is broken up, so I only use half of the content within $FileRead1.
      So its imperative that the $value1, $value2, etc variables be used. 
      Code below:
      $FileRead1 = FileReadLine("C:\temp\sample.txt",1) For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] $value4 = $input[4] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value4, "D1") Next  
    • AnonymousX
      By AnonymousX
      Hello,
      I'm trying to write a script that moves copies excel cells into an array. I'll than manipulate the values and send array into another program. 
      I don't want range to be specific to a workbook, or sheet, or set of cells.
      I want user to be able to highlight desired cells and to copy either normally ("Ctrl+C") or by a hotkey ("Alt+C"). 
      Could someone help me with this?
      Thank you,
      I've tried to write the framework: (edited)
      #include <MsgBoxConstants.au3> #include <Array.au3> #include <Excel.au3> HotKeySet("!v", "Pastedata") While True Sleep(1000) WEnd func Makearray() local $bArray ;User has cells already copied ;Convert clipboard into an array ;I don;t know how excel stores data to clipboard so don;t know how to bring it into array _Arraydisplay($bArray) MsgBox(0,0,$bArray) return $bArray endfunc func Pastedata() Local $aArray MsgBox(0,0,"wait",1) ;make array based on assumption user has already copied a range to clipboard $aArray = Makearray() ;paste code ;don;t worry about this I got the rest endfunc  
×