Jump to content

AutoIT non-array variable?


Kidney
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

×
×
  • Create New...