etidd Posted December 29, 2022 Share Posted December 29, 2022 (edited) Hi all, First time posting here. I will make a handful of these questions here as I walk through my first AutoIt scripts. I am attempting to read the contents of the array after running WinGetPos(). Run("C:\Windows\explorer.exe /n, /e, C:\Users\Username\Music\") WinWaitActive("[ACTIVE]") Send("^n") WinWaitActive("[ACTIVE]") Local $windowSize = WinGetPos("[ACTIVE]") $coordinateMessage = "X: " + $windowSize[0] + ", Y: " + $windowSize[1] + ", width: " + $windowSize[2] + ", height: " + $windowSize[3] MsgBox(0, "Current Window Coordinates", $coordinateMessage) ; MouseClickDrag("left", ) The message box does not preserve the string inside of $coordinateMessage. It simply says the message box title and an integer. The last one only said "1946" and nothing else. Perhaps I have used MsgBox() incorrectly. Thanks in advance for any suggestions. Hopefully this is super easy for somebody to figure out my newbie mistake. 😜 Edited December 29, 2022 by etidd Link to comment Share on other sites More sharing options...
Solution Gianni Posted December 29, 2022 Solution Share Posted December 29, 2022 use the "&" for strings concatenation not "+" etidd 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Musashi Posted December 29, 2022 Share Posted December 29, 2022 18 minutes ago, Gianni said: use the "&" for strings concatenation not "+" Yes. @etidd : ... and you can use underscore _ for multiline concatenation. Example : Local $sMainStr Local $sStr1 = "Happy ", $sStr2 = "New ", $sStr3 = "Year" ; & for concatenation (one line) : $sMainStr = $sStr1 & $sStr2 & $sStr3 ConsoleWrite($sMainStr & @CRLF) ; & _ for multiline concatenation : $sMainStr = $sStr1 & _ $sStr2 & _ $sStr3 ConsoleWrite($sMainStr & @CRLF) "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
ioa747 Posted December 29, 2022 Share Posted December 29, 2022 ... and this line Run("C:\Windows\explorer.exe /n, /e, " & @UserProfileDir & "\Music\") instead Run("C:\Windows\explorer.exe /n, /e, C:\Users\Username\Music\") and in line WinWaitActive("[ACTIVE]") what window are you waiting for ? I know that I know nothing Link to comment Share on other sites More sharing options...
etidd Posted December 29, 2022 Author Share Posted December 29, 2022 (edited) Great replies, all. I learned a lot including the use of underscores for multiline concatenation. The reason the message was originally producing an integer was because the + signs were causing an addition operation of each index in the array. Edited December 29, 2022 by etidd Link to comment Share on other sites More sharing options...
TimRude Posted December 30, 2022 Share Posted December 30, 2022 19 hours ago, etidd said: I am attempting to read the contents of the array after running WinGetPos(). If you're just wanting to see what the array contains as part of your development process while you're writing or debugging a script, have a look at the _ArrayDisplay UDF (user-defined function). For example: #include <Array.au3> Local $windowSize = WinGetPos("[ACTIVE]") _ArrayDisplay($windowSize, "Current Window Coordinates") By the way, WinWaitActive("[ACTIVE]") really doesn't do anything since you're asking AutoIt to wait for the currently active window to become active. So there's nothing to wait for. It's like saying 'wait until 1 equals 1.' It's always immediately true and therefore is meaningless. If you want it to actually wait for a specific window to become active, you need to specify what window by passing either the Title and Text of the window, the window handle, or else using the advanced method for identifying the window. etidd 1 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