JAFN Posted May 23, 2011 Share Posted May 23, 2011 Assume multiple identical windows who's titles all start with '(-)' I am trying to make it so that the windows align under the window cloesest to the top of the screen. Can anyone show me what is wrong with the code below? #Include <Array.au3> OrderWindow("(-)") Func OrderWindows($Mark) $List = WinList($Mark) $Items = $List[0][0] If $Items <= 2 Then Return ;YPos[x][0] = HWND ; [x][1] = Top position Dim $YList[$Items][2] ; create an Array of hwnd and y position For $x = 0 to $Items - 1 $WinPos = WinGetPos($List[$x+1][1]) $YList[$x][0] = $List[$x+1][1] ;hwnd $YList[$x][1] = $WinPos[1] ;y cord ; MsgBox(0,"", $YList[$x][0] & " | " & $YList[$x][1]) Next ;order array by highest window _ArraySort($YList, 0, 0, 0, 1) ;align all windows that titles start with $mark to align under the window highest on screen ;windows are all instances of the same script and are the same height $Left = $YList[0][1] For $x = 1 To $Items-1 ; start at 1 because 0 is the head $WinPos = WinGetPos($YList[$x][0]) $Top = $WinPos[1]; + $WinPos[3] $Left = $WinPos[0] WinMove($YList[$x][0],"", $Left, $Top) Next EndFunc [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 23, 2011 Moderators Share Posted May 23, 2011 JAFN, Can anyone show me what is wrong with the code below?Your coordinates for repositioning the other GUIs is all wrong. Take a look at this script which shows how I would do it: expandcollapse popup#Include <Array.au3> #include <GUIConstantsEx.au3> For $i = 1 To 3 $hGUI = GUICreate("(-)Test " & $i, 200, 100) GUISetState() Next Sleep(5000) ; Allows you rearrange the GUIs you have just created <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OrderWindows("(-)") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func OrderWindows($Mark) ; get list of GUIs Local $List = WinList($Mark) $Items = $List[0][0] If $Items <= 2 Then Return ; Create an Array of hwnd and y position Local $YList[$Items + 1][2] For $x = 1 to $Items $WinPos = WinGetPos($List[$x][1]) $YList[$x][0] = $List[$x][1] ;hwnd $YList[$x][1] = $WinPos[1] ;y cord Next ; Order array by highest window _ArraySort($YList, 0, 0, 0, 1) ; Get position of highest GUI $aBasePos = WinGetPos($YList[1][0]) _ArrayDisplay($aBasePos) ; For interest on;y ; Now reposition the other GUIs For $x = 2 To $Items ; We use the same X coord and add the height of the GUI to each successive GUI to get the Y coord WinMove($YList[$x][0], "", $aBasePos[0], $aBasePos[1] + ($aBasePos[3] * ($x - 1))) Next EndFunc Does it all make sense? Please ask if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JAFN Posted May 23, 2011 Author Share Posted May 23, 2011 Does it all make sense? Please ask if not. M23Thank you for responding so quickly.And for retaining most of what I had done previously. That really helped me to understand it.Wish I still had my first attempt before I started brute forcing it. I'd like to see where I initially screwed up.Again thank you. I think that completes this script. Time to think up another one.JAFN [size="2"]The second mouse gets the cheese[/size] 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