FireFox Posted November 29, 2012 Posted November 29, 2012 (edited) Hi, Is it possible to get the GUI size when all controls are visible ? For example this would be 800x400 if a ctrl is out of the GUI positioned at 700px with a width of 100px from a 400x400 GUI. Another one: the GUI would resize in order to show every control, so to the most [left,top,]right,bottom controls. Thanks for anyhelp. Br, FireFox. Edited November 29, 2012 by FireFox
JohnOne Posted November 29, 2012 Posted November 29, 2012 Your GUI, or third party? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
FireFox Posted November 29, 2012 Author Posted November 29, 2012 Your GUI, or third party?hm, only ctrls inside the GUI so I suppose my GUI.
JohnOne Posted November 29, 2012 Posted November 29, 2012 I think you would use GUIRegisterMsg and act upon $WM_SIZE message to get new size. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
FireFox Posted November 29, 2012 Author Posted November 29, 2012 (edited) I think you would use GUIRegisterMsg and act upon $WM_SIZE message to getnew size.How that? It gives only the new client size and not what I want.Because, my starting point is that I don't know the position of the bound ctrls. Edited November 29, 2012 by FireFox
JohnOne Posted November 29, 2012 Posted November 29, 2012 Then I don't understand the question. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
jdelaney Posted November 29, 2012 Posted November 29, 2012 Unless you have a GuiWidth and GuiHeight variable you are keeping current, the best way I can think is to loop through all controls, get their positions, and find the max height/width. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
FireFox Posted November 29, 2012 Author Posted November 29, 2012 Unless you have a GuiWidth and GuiHeight variable you are keeping current, the best way I can think is to loop through all controls, get their positions, and find the max height/width.Yes that's what I have for the moment, but it's too crap.@JohnOneImagine the left GUI contains ctrls, it has a client size of 200x200, but this one has a label out of its client size.I have resized the GUI to show this label and in green is the size I want.
jdelaney Posted November 29, 2012 Posted November 29, 2012 (edited) looks like bad logic on your guiheight/width variables Should be GuiWidth+=(newcontrolwidth+bufferinbetweencontrols) Need the code to validate Edited November 29, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Bert Posted November 29, 2012 Posted November 29, 2012 I think I know what you are asking for but forgive me if I speak out of turn. If you create an array that list all the controls, sizes and locations you then could use the control that has the highest number for position for the Y axis and the control that has the highest number for position for the X axis. You then add in the size of the control and a small amount for the border. This method I'm pretty certain is clunky and I would think there would be a better solution but this would (logic suggest) work. The Vollatran project My blog: http://www.vollysinterestingshit.com/
FireFox Posted November 29, 2012 Author Posted November 29, 2012 (edited) looks like bad logic on your guiheight/width variablesShould be GuiWidth+=(newcontrolwidth+bufferinbetweencontrols)Need the code to validateRead my reply #5.This will be for an UDF, so I prefer it to auto detect "bound ctrls" instead of the user to provide the data. Edited November 29, 2012 by FireFox
jdelaney Posted November 29, 2012 Posted November 29, 2012 (edited) this would work...make it a function call: $hApplication = "your application name or handle" $slist = WinGetClassList ( $hApplication ) $alist = StringSplit ($slist, @CRLF) _ArrayDelete($alist, 0) _ArrayDelete($alist, UBound($alist)-1) _ArraySort($alist) $priorclass = "" $maxWidth = 0 $maxHeight = 0 For $i = 0 To UBound ( $alist ) - 1 If $alist[$i] <> $priorclass Then $counter = 1 $priorclass = $alist[$i] $aPos = ControlGetPos ( $hApplication, "", "[CLASSNN:" & $alist[$i] & $counter & "]" ) If $aPos[0]+$aPos[2] > $maxWidth Then $maxWidth = $aPos[0]+$aPos[2] If $aPos[1]+$aPos[3] > $maxHeight Then $maxHeight = $aPos[1]+$aPos[3] $counter+=1 Next MsgBox ( 1,1, "MaxWidth=[" & $maxWidth & "]; MaxHeight=[" & $maxHeight & "]" ) Edited November 29, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
FireFox Posted November 29, 2012 Author Posted November 29, 2012 (edited) @jdelaney Thanks for the snippet, but as I said I'm searching for fast solution that would take the same time to get the bound area with 1 or 10000 ctrls. If no solution is given, I will use yours , Note : you need to remove this : _ArrayDelete($alist, 0) Edited November 29, 2012 by FireFox
jdelaney Posted November 29, 2012 Posted November 29, 2012 (edited) I don't like the auto added counters of arrays, I remove them suppose i could have used flag 2 on stringsplit, but oh well: flag = 2, disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case). Edited November 29, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
FireFox Posted November 29, 2012 Author Posted November 29, 2012 I don't like the auto added counters of arrays, I remove them It's not about that, If you don't remove the line, your script does not work.P.S : use the flag 2 to remove the count index.
jdelaney Posted November 29, 2012 Posted November 29, 2012 (edited) You will need to add condition handling to validate there are controls present...that's probably the issue. My snippet works, as is, when controls are present. edit: updated: $hApplication = "title" $slist = WinGetClassList ( $hApplication ) $alist = StringSplit ($slist, @CRLF, 2) If Not IsArray ($alist) And StringLen ($slist)>0 Then Dim $alist[1] $alist[0]=$slist EndIf If IsArray ($alist) Then For $i = UBound ( $alist ) - 1 To 0 Step -1 If StringLen ( StringStripWS ($alist[$i], 8 ) ) = 0 Then _ArrayDelete ($alist, $i) Next Else MsgBox (1,1,"invalid win handle/title, or no controls" ) EndIf $priorclass = "" $maxWidth = 0 $maxHeight = 0 For $i = 0 To UBound ( $alist ) - 1 If $alist[$i] <> $priorclass Then $counter = 1 $priorclass = $alist[$i] $aPos = ControlGetPos ( $hApplication, "", "[CLASSNN:" & $alist[$i] & $counter & "]" ) If $aPos[0]+$aPos[2] > $maxWidth Then $maxWidth = $aPos[0]+$aPos[2] If $aPos[1]+$aPos[3] > $maxHeight Then $maxHeight = $aPos[1]+$aPos[3] $counter+=1 Next MsgBox ( 1,1, "MaxWidth=[" & $maxWidth & "]; MaxHeight=[" & $maxHeight & "]" ) Edited November 29, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
FireFox Posted November 29, 2012 Author Posted November 29, 2012 You will need to add condition handling to validate there are controls present...that's probably the issue. My snippet works, as is, when controls are present.No, I have a label, it's rather if there is one or more ctrls.
jdelaney Posted November 29, 2012 Posted November 29, 2012 gotcha, updated IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
JohnOne Posted November 29, 2012 Posted November 29, 2012 (edited) Still totally baffled by this thread. If you are making a gui (still unclear) , you should know the dimensions of any controls before it is creatred, and if not, I doubt there is other possible way to get that info other than loop through the controls. If you are making the gui and user is resizing controls then you need to get that info on the fly. getting the size of largest control of 1000 3rd party windows in the same time as in 1, is a completely unrealistic expectation Edited November 29, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
jdelaney Posted November 29, 2012 Posted November 29, 2012 I agree with John. I have several gui's that create/delete new 'column' of controls, or a new 'row' of controls to basically make lists...and I do width/height modifications by adding/subtracting the control width/height and a buffer on the fly IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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