Burgaud Posted February 6, 2021 Share Posted February 6, 2021 Here is my code: #include <Array.au3> #include <Process.au3> #include <WinAPIProc.au3> while 1 local $aArray = WinList() ;$aArray[0][0] = Number of windows returned ;$aArray[1][0] = 1st window title ;$aArray[1][1] = 1st window handle (HWND) for $i = 1 to $aArray[0][0] $aArray[$i][2] = WinGetState($aArray[$i][1]) next _ArrayDisplay($aArray, "WinList") wend Obviously, the line $aArray[$i][2] = WinGetState($aArray[$i][1]) does not work. Why? I am very weak with Autoit's array. And from my "weak" understanding of the above is that, $aArray is not an actual array because of the way it was created and filled? And if so, how can I resolve the above? Should I create a real array local $Array[x][y] and _ArrayAdd ($Array, ...) into it in the for loop? Link to comment Share on other sites More sharing options...
TheXman Posted February 6, 2021 Share Posted February 6, 2021 (edited) 1 hour ago, Burgaud said: Obviously, the line $aArray[$i][2] = WinGetState($aArray[$i][1]) does not work. Why? Because the array created by WinList has 2 columns (Title & Hwnd). You attempted to place a value (Window state) in a non-existent 3rd column. One way to do what you are trying to do is to add a 3rd column to the array by using ReDim and then add your window states. #include <Array.au3> #include <Process.au3> #include <WinAPIProc.au3> Global $aArray = WinList() ;$aArray[0][0] = Number of windows returned ;$aArray[1][0] = 1st window title ;$aArray[1][1] = 1st window handle (HWND) ReDim $aArray[UBound($aArray)][3] ;Add 3rd column to the WinList array For $i = 1 To $aArray[0][0] $aArray[$i][2] = WinGetState($aArray[$i][1]) Next _ArrayDisplay($aArray, "WinList", "", 0, Default, "Title|Hwnd|State") Edited February 6, 2021 by TheXman Burgaud 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Skysnake Posted February 22, 2021 Share Posted February 22, 2021 https://www.autoitscript.com/wiki/Arrays#Comparing_Arrays Please see this explanation? Skysnake Why is the snake in the sky? 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