Jump to content

[CLOSED] Get the GUI size when all controls are visible


FireFox
 Share

Recommended Posts

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

I think you would use GUIRegisterMsg and act upon $WM_SIZE message to get

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

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.
Link to comment
Share on other sites

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.

@JohnOne

Posted Image

Imagine 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.

Link to comment
Share on other sites

looks like bad logic on your guiheight/width variables

Should be GuiWidth+=(newcontrolwidth+bufferinbetweencontrols)

Need the code to validate

Edited 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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

looks like bad logic on your guiheight/width variables

Should be GuiWidth+=(newcontrolwidth+bufferinbetweencontrols)

Need the code to validate

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

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 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.
Link to comment
Share on other sites

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

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 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.
Link to comment
Share on other sites

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 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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

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.
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

×
×
  • Create New...