dantay9 Posted May 31, 2009 Posted May 31, 2009 (edited) #include <Array.au3> Dim $GUI[2], $GUI_Pos[2] $GUI[1] = GUICreate("Test1", 200, 25, 5, 5) $GUI_Pos[1] = WinGetPos($GUI[1]) ;~ _ArrayDisplay($GUI_Pos[1]) This is just a simple script that will help me understand how to use 2D arrays. How do I get: $GUI_Pos[1][0] = 5 $GUI_Pos[1][1] = 5 $GUI_Pos[1][2] = 206 $GUI_Pos[1][3] = 55 Kind of like consolidating two arrays into a single array. I guess arrays should have been one of the first things I learned. Edited May 31, 2009 by dantay9
Valuater Posted May 31, 2009 Posted May 31, 2009 Maybe... #include <Array.au3> Dim $GUI[2], $GUI_Pos[2][4] $GUI[1] = GUICreate("Test1", 200, 25, 5, 5) GUISetState() $Get_GUI_Pos = WinGetPos($GUI[1]) _ArrayDisplay($Get_GUI_Pos) $GUI_Pos[1][0] = $Get_GUI_Pos[0] ; 5 $GUI_Pos[1][1] = $Get_GUI_Pos[1] ; 5 $GUI_Pos[1][2] = $Get_GUI_Pos[2] ; 206 $GUI_Pos[1][3] = $Get_GUI_Pos[3] ; 55 _ArrayDisplay($GUI_Pos) 8)
dantay9 Posted May 31, 2009 Author Posted May 31, 2009 Yes, I know that, but I am going to have an unknown number of windows to move. My plan is to use a for loop around the wingetpos() so I can get the position of each window. So... Dim $GUI[2], $GUI_Pos[2][4] $GUI[0] = GuiCreate("Test2", 200, 25, 15, 30) GUISetState() $GUI[1] = GUICreate("Test1", 200, 25, 5, 5) GUISetState() For $x = 0 to Ubound($GUI) $GUI_Pos[$x] = WingetPos($GUI[$x]) Next Syntax -- $GUI_Pos[window number][0-4 from wingetpos()] $GUI_Pos[1][0] = 5 $GUI_Pos[1][1] = 5 $GUI_Pos[1][2] = 206 $GUI_Pos[1][3] = 55
Authenticity Posted May 31, 2009 Posted May 31, 2009 (edited) Nope, I guess it doesn't work this way. When you store array in an array element you can access it only by assigning it to another temporary variable like: Dim $avArray[2], $avArr1[2] = [1, 1], $avArr2[2] = [2, 2] $avArray[0] = $avArr1 $avArray[1] = $avArr2 For $i = 0 To UBound($avArray)-1 Local $aTmp = $avArray[$i] If IsArray($aTmp) Then For $j = 0 To UBound($aTmp)-1 ConsoleWrite($aTmp[$j] & @TAB) Next ConsoleWrite(@CRLF) EndIf Next Edited May 31, 2009 by Authenticity
Bert Posted May 31, 2009 Posted May 31, 2009 Give this a read. It make things clearer for you.http://www.autoitscript.com/wiki/index.php?title=Arrays The Vollatran project My blog: http://www.vollysinterestingshit.com/
Valuater Posted May 31, 2009 Posted May 31, 2009 Ya know, I did something similar in FreeText.au3 if you want to have a look....http://www.autoitscript.com/forum/index.ph...st&p=5279128)
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