Code: Select all
for oWB in ComObjCreate("Shell.Application").Windows
Thank you.
[EDIT:] This issue is resolved here:
Cast COM Object IWebBrowser2 to IServiceProvider - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=67163
Code: Select all
for oWB in ComObjCreate("Shell.Application").Windows
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
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("GetParent", UInt, hCtl), hCtl3 := DllCall("GetParent", UInt, hCtl2)
ControlGetText, vTitle, , ahk_id %hCtl3%
if (SubStr(vTitle, 1-20) = " - Internet Explorer")
StringTrimRight, vTitle, vTitle, 20
if (oWB.LocationUrl ~= "blank")
continue
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 .= "`r`n"
controlOuterHTML := oWB.document.documentElement.outerHTML
oWB := ""
}
;===============
vOutput .= "[ORDER 2: OBJECT ORDER]`r`n"
;get url + title, object order
for oWB in ComObjCreate("Shell.Application").Windows
{
objectHwnd := ""
try {
objectHwnd := oWB.Hwnd
}
if (Hwnd != objectHwnd)
continue
vOutput .= oWB.LocationName "`r`n"
vOutput .= oWB.LocationUrl "`r`n"
vOutput .= "`r`n"
objectOuterHTML := oWB.document.documentElement.outerHTML
}
oWB := ""
if (SubStr(vOutput, 1-4) = "`r`n`r`n")
StringTrimRight, vOutput, vOutput, 2
match := % (controlOuterHTML = objectOuterHTML) ? "they match" : "they don't match"
MsgBox,
(LTrim
%vOutput%
--------------------
%match%
)
Return
WBGet(WinTitle="ahk_class IEFrame", Svr#=1) { ;// based on ComObjQuery docs
static msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
, IID := "{0002DF05-0000-0000-C000-000000000046}" ;// IID_IWebBrowserApp
;// , IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ;// IID_IHTMLWindow2
SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
if (ErrorLevel != "FAIL") {
lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
}
}
} ; by jethrow
Code: Select all
startTime := A_TickCount
Sleep, 1000
MsgBox, 0, Run time, % endTime := A_TickCount - startTime
Code: Select all
^q::
WinGet, hWnd, ID, ahk_class IEFrame
vOutput := ""
for oWB in ComObjCreate("Shell.Application").Windows
{
if (hWnd = oWB.HWND)
vOutput .= oWB.document.title "`r`n" oWB.LocationUrl "`r`n`r`n"
}
oWB := ""
vOutput := SubStr(vOutput, 1, -2) ;trim right
Clipboard := vOutput
MsgBox, % "done"
return
Code: Select all
;WBGet function - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=39869
vCount := 0
q:: ;internet explorer tab - set property
vCount++
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
oWB.PutProperty("MyProperty", vCount)
oWB := ""
return
w:: ;internet explorer tab - get property
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
MsgBox, % oWB.GetProperty("MyProperty")
oWB := ""
return
e:: ;internet explorer tab - set property
DetectHiddenWindows, On
WinGet, vWinList, List, ahk_class IEFrame
Loop % vWinList
{
hWnd := vWinList%A_Index%
WinGet, vCtlList, ControlList, % "ahk_id " hWnd
Loop Parse, vCtlList, % "`n"
{
ControlGet, hCtl, Hwnd,, % "Internet Explorer_Server" A_Index, % "ahk_id " hWnd
if !hCtl
break
oWB := WBGet("ahk_id " hWnd, A_Index)
oWB.PutProperty("MyProperty", hCtl)
oWB := ""
}
}
return
Users browsing this forum: AlFlo and 136 guests