window get controls (indented to show hierarchy)

Post your working scripts, libraries and tools.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

window get controls (indented to show hierarchy)

24 Oct 2019, 16:53

E.g. try this on the Notepad Font dialog or Internet Explorer.

Code: Select all

q:: ;window get control info with indentation to indicate hierarchy
hWnd := WinGetID("A")
MsgBox(Clipboard := JEE_WinGetDescendants(hWnd))
return

JEE_WinGetDescendants(hWnd)
{
	local
	DetectHiddenWindows("On")
	oCtlList := WinGetControls("ahk_id " hWnd)
	vOutput := ""
	Loop oCtlList.Length
	;Loop % oCtlList.Length() ;AHK v1
	{
		vCtlClassNN := oCtlList[A_Index]
		hCtl := ControlGetHwnd(vCtlClassNN, "ahk_id " hWnd)
		vPfx := ""
		Loop
		{
			hCtl := DllCall("user32\GetAncestor", "Ptr",hCtl, "UInt",1, "Ptr") ;GA_PARENT := 1
			if (hCtl = hWnd)
				break
			vPfx .= "`t"
		}
		vOutput .= vPfx vCtlClassNN "`r`n"
	}
	return vOutput
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: window get controls (indented to show hierarchy)

27 Oct 2019, 11:52

not sure you need to force-local the function. am i missing something?

User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: window get controls (indented to show hierarchy)

27 Oct 2019, 12:01

I force local in all of my functions to prevent #Warn errors.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: No registered users and 24 guests