Cann't access to frame at different domain when automate IE Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
xcracked
Posts: 15
Joined: 29 Sep 2018, 22:27

Cann't access to frame at different domain when automate IE

11 Apr 2019, 10:36

Hi, Everybody
These days, I have been learnt to Automate Internet Explorer. But, When I comes to get the element in frame/iframes at different domains, errors come out:ACCESSDENIED.And my method is:
objIE := WBGET()
objIE.document.frames["xxxx"].frames["xxxx"].document.getElementById........
this works when frames froms same domain, fail if froms different domain.
Any ideals will be helpful, sorry for my bad english.Thanks!
User avatar
tank
Posts: 2850
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: Cann't access to frame at different domain when automate IE  Topic is solved

11 Apr 2019, 11:12

you have to query for the document object from the documentElement

Code: Select all

IHTMLWindow2_from_IWebDOCUMENT( IWebDOCUMENT )
        {
        static IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"  ; IID_IHTMLWindow2
        return ComObj(9,ComObjQuery( IWebDOCUMENT, IID_IHTMLWindow2, IID_IHTMLWindow2),1)
        }

Code: Select all

frameDoc := IHTMLWindow2_from_IWebDOCUMENT( objIE.document.frames["xxxx"].documentElement )
Havent tested or done this in a while but that is what i recal
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:
xcracked
Posts: 15
Joined: 29 Sep 2018, 22:27

Re: Cann't access to frame at different domain when automate IE

12 Apr 2019, 09:30

tank wrote:
11 Apr 2019, 11:12
you have to query for the document object from the documentElement

Code: Select all

IHTMLWindow2_from_IWebDOCUMENT( IWebDOCUMENT )
        {
        static IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"  ; IID_IHTMLWindow2
        return ComObj(9,ComObjQuery( IWebDOCUMENT, IID_IHTMLWindow2, IID_IHTMLWindow2),1)
        }

Code: Select all

frameDoc := IHTMLWindow2_from_IWebDOCUMENT( objIE.document.frames["xxxx"].documentElement )
Havent tested or done this in a while but that is what i recal
thanks, I will try this out!
xcracked
Posts: 15
Joined: 29 Sep 2018, 22:27

Re: Cann't access to frame at different domain when automate IE

13 Apr 2019, 00:53

Thanks,tank. Your code works nice.I have three frames at different domains,this is my code:

Code: Select all

rightFrameDoc := IHTMLWindow2_from_IWebDOCUMENT(objIE.document.frames["rightFrame"].document)
mainFrameDoc := IHTMLWindow2_from_IWebDOCUMENT(rightFrameDoc.frames["mainFrame"].document)
num := mainFrameDoc.document.frames["chiframe"].document.getElementById("capitalFl").Click()
User avatar
tank
Posts: 2850
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: Cann't access to frame at different domain when automate IE

13 Apr 2019, 11:58

glad it helped
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:

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, BeSu, Lee James, mikeyww, pizzapizze, Saarthak Kamra, samzz and 48 guests