Kidney Posted October 13, 2011 Posted October 13, 2011 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??
water Posted October 13, 2011 Posted October 13, 2011 In your case $Buy is no array. Check for errors after each PixelSearch. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
Kidney Posted October 13, 2011 Author Posted October 13, 2011 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??
Shaggi Posted October 13, 2011 Posted October 13, 2011 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
water Posted October 13, 2011 Posted October 13, 2011 I suggest you read the help file. All info can be found there. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
Kidney Posted October 13, 2011 Author Posted October 13, 2011 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
Ramzes Posted October 13, 2011 Posted October 13, 2011 It looks like a bot. Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now