@phaleth Thank you, that's the curious thing, there's so much information you can get from a document object, you wonder if there is some actual object ID available that would give certainty, that would tie together the items in the two separate loops, furthermore you don't know if the number of tags will change between loops.
Also for example you could have the same url, but say a timestamp in the title that changed between the two loops, so here a common ID would be very useful.
I've provided a basic version of each loop to demonstrate how the initial data is retrieved. Getting the title via the frame tab is security against object Internet titles that have 'gone wrong' e.g. by clearing IE's history, which usually makes the 'title' the same as the url.
Also the frame tab control might say 'hello - Google Search' where as the document object says less usefully: 'Google'.
It should be noted that the frame tab text is usually truncated at 95 characters.
If there is some clash, between the title texts, a prefix such as '[ERROR]' can be added to the front of the retrieved title, for the user to then double-check the title themselves, or perhaps even use a function to download the url to a variable and retrieve the title.
Code: Select all
WinGet, hWnd, ID, ahk_class IEFrame
vOutput := "[ORDER 1: CONTROL ORDER]`r`n"
;get url + title, control order
Loop
{
ControlGet, hCtl, Hwnd,, % "Internet Explorer_Server" A_Index, % "ahk_id " hWnd
if (hCtl = "")
break
;Frame Tab\TabWindowClass\Shell DocObject View\Internet Explorer_Server
ControlGet, hCtl, Hwnd,, % "Internet Explorer_Server" A_Index, % "ahk_id " hWnd
hCtl2 := DllCall("user32\GetParent", "Ptr",hCtl, "Ptr")
, hCtl3 := DllCall("user32\GetParent", "Ptr",hCtl2, "Ptr")
ControlGetText, vTitle,, % "ahk_id " hCtl3
vIsV1 := !!SubStr(1, 0)
if (SubStr(vTitle, vIsV1-20) = " - Internet Explorer")
vTitle := SubStr(vTitle, 1, -20)
vOutput .= vTitle "`r`n"
;WBGet: https://autohotkey.com/board/topic/47052-basic-webpage-controls-with-javascript-com-tutorial/
oWB := WBGet("ahk_id " hWnd, A_Index)
;vOutput .= oWB.LocationName "`r`n"
;vOutput .= oWB.LocationUrl "`r`n"
vOutput .= oWB.document.title "`r`n"
vOutput .= oWB.document.url "`r`n"
oWB := ""
vOutput .= "`r`n"
}
;===============
vOutput .= "[ORDER 2: OBJECT ORDER]`r`n"
;get url + title, object order
for oWB in ComObjCreate("Shell.Application").Windows
{
if !(hWnd = oWB.Hwnd)
continue
;vOutput .= oWB.LocationName "`r`n"
;vOutput .= oWB.LocationUrl "`r`n"
vOutput .= oWB.document.title "`r`n"
vOutput .= oWB.document.url "`r`n"
vOutput .= "`r`n"
}
oWB := ""
vIsV1 := !!SubStr(1, 0)
if (SubStr(vOutput, vIsV1-4) = "`r`n`r`n")
vOutput := SubStr(vOutput, 1, -2)
Clipboard := vOutput
MsgBox, % "done"
return