Page 1 of 1

pwb get element from another tab

Posted: 05 Dec 2017, 06:53
by HIAC

Code: Select all

ypwb := ComObjCreate("InternetExplorer.Application")
ypwb.Visible := true
ypwb.Navigate("https://ytmp3.cc/")
ypwb.Navigate("https://www.youtube.com/results?search_query=Song", 2048)
while ypwb.busy or ypwb.ReadyState !=4
	sleep, 10
Alright so I have two tabs open, how can I tell which one to get element from?

Re: pwb get element from another tab

Posted: 05 Dec 2017, 09:11
by tank
you dont have a pointer to the second tab. you would need to use wbget(pagename) to get it

Re: pwb get element from another tab

Posted: 05 Dec 2017, 09:44
by HIAC
Example please?

Re: pwb get element from another tab

Posted: 05 Dec 2017, 10:18
by tank

Code: Select all

ypwb := ComObjCreate("InternetExplorer.Application")
ypwb.Visible := true
ypwb.Navigate("https://ytmp3.cc/")
ypwb.Navigate("https://www.youtube.com/results?search_query=Song", 2048)
while ypwb.busy or ypwb.ReadyState !=4
	sleep, 10

pwb := WBGet() ;; new active tab

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)
      }
   }
}

Re: pwb get element from another tab

Posted: 05 Dec 2017, 10:22
by jeeswg
In which case it might be better to do this twice:
ypwb := ComObjCreate("InternetExplorer.Application")
Well, give the second one a different name e.g. ypwb2.

Btw you can use this to check which tab an object refers to:
MsgBox, % ypwb.document.title "`r`n" ypwb.document.url

Re: pwb get element from another tab

Posted: 05 Dec 2017, 11:37
by HIAC
Thanks.

If I create two different objects, then set both visibility to false, they'll show up no matter