babysnails Posted January 31, 2017 Share Posted January 31, 2017 Hi. I started using AutoIt yesterday and right now I'm trying to write my first program. I am trying to do the following: 1) create an array that is the size of a map on a website (in pixels) 2) populate the array with each corresponding pixel color (hex value) 3) display the array to make sure it worked This is what I have so far: #include <Array.au3> $x = WinActivate("Website") Global $map[510][330] ;the map is 510 pixels wide, 330 pixels tall Global $mapRows = UBound($map, 1) ;this should be 330 Global $mapCols = UBound($map, 2) ;this should be 510 ;ignore the while loop. it will come into play for me later ;while(1) for $i = 0 to $mapCols - 1 ;i think this should iterate over all the pixels that are aligned horizontally across the map for $j = 0 to $mapRows - 1 ;same as above but vertically $map[$i][$j] = PixelGetColor($i + 305,$j + 29) ;i know that i want to start collecting pixels at (305,29) (this is the top left part of the map) Next Next ;Exit ;WEnd _ArrayDisplay($map, "Map", Default, 1) I get this error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $map[$i][$j] = PixelGetColor($i + 305,$j + 29) To me the statement $map[$i][$j] = PixelGetColor($i + 305,$j + 29) means this (on its first iteration): Get the hex value of the pixel at (305,29) and place it in the element which is at the first row and column of the array called map. Can someone please help me figure out what I am doing wrong here? Thanks! Link to comment Share on other sites More sharing options...
careca Posted January 31, 2017 Share Posted January 31, 2017 I get the same, you do have $map[$i][$j] maybe there's a mixup of array variables? i mean, you use $i and $j and then state those again... If i was home, i'd try to change the resulting variables $map[$x][$y] = PixelGetColor or something. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
RTFC Posted January 31, 2017 Share Posted January 31, 2017 you mixed up rows and cols ($i = rows, $j =cols). My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
babysnails Posted January 31, 2017 Author Share Posted January 31, 2017 Thank you for the replies. I tried switching rows and cols and now do not get an error! However, when i do this the program doesn't seem to do anything. Is there something I need to do after calling _ArrayDisplay($map, "Map", Default, 1) ? Maybe creating this array is just a slow process? Link to comment Share on other sites More sharing options...
babysnails Posted January 31, 2017 Author Share Posted January 31, 2017 Sorry for a double post but I dont know how to edit my last post. It turns out that I did indeed have rows and cols reversed. After I fixed this, the reason I wasnt getting any output was that the array was simply too large! documentation on ArrayDisplay states that the function can output 65525 rows but only 250 columns. I am going to go ahead and scale my array back to full size and assume it works after this little experiment. Thanks! Link to comment Share on other sites More sharing options...
careca Posted February 1, 2017 Share Posted February 1, 2017 You edit by clicking Edit at bottom of your post. In the area where "Quote" is for all posts. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
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