Modify ↓
Opened 3 weeks ago
Last modified 2 weeks ago
#4063 assigned Bug
ControlGetPos does not return info about a nested Child window
| Reported by: | Jpm | Owned by: | Jon |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.14.0 | Severity: | None |
| Keywords: | Cc: |
Description (last modified by mLipok)
here a repro example
#include <GUIConstantsEx.au3> #include <WinAPISysWin.au3> #include <WindowsStylesConstants.au3> Local $hGUI = GUICreate("ControlGetPos() ", 400, 350) Local $idInfo = GUICtrlCreateLabel("test", 10, 200, 380, 150) Local $hChild_1 = GUICreate("Child_1", 280, 180, 70, 10, BitOR($WS_CHILD, $WS_VISIBLE), -1, $hGUI) ; 10 pixels inside GUI GUISetBkColor(0xFFFF00) ; yellow Local $hChild_2 = GUICreate("Child_2", 240, 140, 20, 20, BitOR($WS_CHILD, $WS_VISIBLE), -1, $hChild_1) ; + 20 pixels inside $hChild_1 GUISetBkColor(0xC0FFFF) ; light blue Local $idBtn = GUICtrlCreateButton("Button", 40, 40, 80, 30) ; + 40 pixels inside $hChild_2 (that's 10+20+40 = 70 pixels inside GUI) Local $aPos1 = ControlGetPos($hChild_1, "", $idBtn); relative coord in Child1 Local $aPos = ControlGetPos($hGUI, "", $idBtn) ; to be used for instance in MouseMove() relative to GUI client area Local $aPos2 = ControlGetPos($hChild_2, "", $idBtn); relative coord in Child2 Local $hBtn = GUICtrlGetHandle($idBtn) Local $hAncestor = _WinAPI_GetAncestor($hBtn, $GA_ROOT) ; = $hGUI Local $hParent = _WinAPI_GetAncestor($hBtn, $GA_PARENT) ; = $hChild_2 GUISetState(@SW_SHOW, $hGUI) Local $sText = "$hGUI = " & $hGUI & " $hChild_1 = " & $hChild_1 & " $hChild_2 = " & $hChild_2 & @CRLF & _ "Ancestor $GA_ROOT = " & $hAncestor & " Ancestor $GA_PARENT = " & $hParent & @CRLF & @CRLF & _ "Button ControlGetPos Child2 : X = " & $aPos2[0] & " / Y = " & $aPos2[1] & @CRLF & _ "Button ControlGetPos Child1 : X = " & $aPos1[0] & " / Y = " & $aPos1[1] & @CRLF & _ "Button ControlGetPos GUI : X = " & $aPos[0] & " / Y = " & $aPos[1] & @CRLF GUICtrlSetData($idInfo, $sText) Local $aCtrl[3] = ["Child2", "Child1", "GUI "] Local $iCtrl = 0 ; Click on the button from specific control or window ControlClick($hChild_2, "", $idBtn, "left", 1) ControlClick($hChild_1, "", $idBtn, "left", 1) ControlClick($hGUI, "", $idBtn, "left", 1) Opt("MouseCoordMode", 2) ; relative to GUI client area MouseMove($aPOS[0], $aPOS[1]) ; move to the upper left of the button While 1 Switch (GUIGetMsg()) Case $idBtn If $iCtrl < UBound($aCtrl) Then $sText &= @CRLF & ">>>>>>>>>> BTN clicked in " & $aCtrl[$iCtrl] & " <<<<<<<<<<<<<<" GUICtrlSetData($idInfo, $sText) Else Tooltip('BTN Clicked') Sleep(2000) Tooltip('') EndIf $iCtrl += 1 Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd
Attachments (0)
Change History (2)
comment:1 Changed 3 weeks ago by Jpm
- Owner set to Jon
- Status changed from new to assigned
comment:2 Changed 2 weeks ago by mLipok
- Description modified (diff)
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Note: See
TracTickets for help on using
tickets.

Fix sent to Jon