martin Posted April 25, 2009 Share Posted April 25, 2009 (edited) If you need to resize or move child windows the WinGetPos function is awkward because the position returned is in screen coordinates, whereas WinMove uses coordinates relative to the parent client 0,0 position.Authenticity pointed that out that ControlGetPos does the job but not for the position of a child in a child whereas this does.expandcollapse popup; #FUNCTION# ================================================================================ ; Name...........: _WinGetPosIn ; Description ...: Returns an array of coordinates for $childw with the position coordinates ; relative to the 0,0 client area of $parentW ; Parameters .... $childw the window handle or title whose position is required ; $childText the text in the child window (can be "") ; $parentw ; $parentText ; On success ; returns an array with 4 elements ; [x,y,childwidth,childheight] ; where x,y is the position relative to the parent client area 0,0 ; On failure ; returns 0 and sets @error to 1 ; and sets @Extended to 1 if the $ChildW is not a window ; 2 if $parentW is not a window ; 3 if either window is minimized ; 4 if failed to get coordinates for $parentw ; NOTE- It is not required that $childW is actually a child of $parentW ; although this is when the function is most useful ;============================================================================================ Func _WinGetposIn($parentW,$parentText,$childW,$childText="") Local $Result, $offset if Not WinExists($childw) then return seterror(1,1,0) if Not WinExists($parentw) then return seterror(1,2,0) If BitAND(WinGetState($childW), 16) Or BitAND(WinGetState($parentW), 16) Then Return seterror(1,3,0) $offset = dllstructcreate("int;int") DllCall("User32.dll", "int", "ClientToScreen", "hwnd", WinGetHandle($parentW,$parentText), "ptr", DllSTructGetPtr($offset)) if @error then return seterror(1,4,0) $Result = wingetpos($childW, $childText) $Result[0] -= dllstructgetdata($offset,1) $Result[1] -= dllstructgetdata($offset,2) return $Result EndFuncUse ControlGetPos unless you need the position of a window in a child window.EDIT: Changed to make it the same format as ControlGetPosmgrefWingetPosIn Edited May 15, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Authenticity Posted April 25, 2009 Share Posted April 25, 2009 And what about ControlGetPos? Link to comment Share on other sites More sharing options...
martin Posted April 25, 2009 Author Share Posted April 25, 2009 And what about ControlGetPos?Well I never thought to use ControlGetPos for a child window, but now you say that It would be obvious. I'll try it.Yes, of course it works. Thanks authenticity. I'll leave the post as a monument to my stupidity. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
martin Posted April 25, 2009 Author Share Posted April 25, 2009 Well I never thought to use ControlGetPos for a child window, but now you say that It would be obvious. I'll try it.Yes, of course it works. Thanks authenticity. I'll leave the post as a monument to my stupidity.But then again I found that in the script I was using it ControlGetPosition desn't work for a window in a child window so I'm not quite so stupid maybe. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
yehia Posted April 26, 2009 Share Posted April 26, 2009 YES YES YES totally true 2 days ago i wasnt able to get the pos of a control on child win thanks a lot that really helped My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine 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