Jump to content

Quick Question


Recommended Posts

#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 by dantay9
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...