pwb get element from another tab

Get help with using AutoHotkey and its commands and hotkeys
HIAC
Posts: 111
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

pwb get element from another tab

05 Dec 2017, 06:53

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?
User avatar
tank
Posts: 2821
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: pwb get element from another tab

05 Dec 2017, 09:11

you dont have a pointer to the second tab. you would need to use wbget(pagename) to get it
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
HIAC
Posts: 111
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Re: pwb get element from another tab

05 Dec 2017, 09:44

Example please?
User avatar
tank
Posts: 2821
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: pwb get element from another tab

05 Dec 2017, 10:18

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)
      }
   }
}
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: pwb get element from another tab

05 Dec 2017, 10:22

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
HIAC
Posts: 111
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Re: pwb get element from another tab

05 Dec 2017, 11:37

Thanks.

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

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler and 217 guests