Frames and COM Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Crashm87
Posts: 48
Joined: 25 Jul 2016, 13:12

Frames and COM

07 Mar 2017, 10:17

Morning everyone.

I'm having trouble understanding how to access frames in IE using COM.

Was wondering if someone can spell this out for me.
I need access this input, <INPUT>[27]. see Screenshot
Image

This is giving me an error. myFrame := wb.document.parentWindow.frames[1].document when it tried to actually push my variable into the input.
Spoiler
Thanks in advance
enter8
Posts: 102
Joined: 05 May 2016, 16:48

Re: Frames and COM

08 Mar 2017, 11:35

In my experience working with dom elements, if I'm having trouble getting an element, I typically try moving up in the hierarchy and seeing if I can get a parent (or a parent's parent).

What does this give you?

Code: Select all

myFrame := document.parentWindow.frames[1].document.body.innerHTML
msgbox % myFrame
Based on testing that I've done, this may/may not include the element you're looking for, but it will tell you if you're targeting the frame properly (by producing something), and, if you are, that will tell you that you that it may not be a frame issue, but, rather, it may relate to the input component of your javascript.

This targets the entire frame. If you can find something in the hierarchy between the whole frame and your target element, try getting that also.
Crashm87
Posts: 48
Joined: 25 Jul 2016, 13:12

Re: Frames and COM

08 Mar 2017, 13:42

Thank you. That pointed me EXACTLY where I needed to go. I was able to figure out what the problem is from your post, and not sure if there is way to 'work around' this or not.

What's happening is, the frame count changes depending on how my browser reaches the screen. If it is the first time I go to the screen in the mornings, I get:
Image

If i submit a claim, it takes me back to the same screen, but the frame is:
Image
So it takes away one from for some reason after it reloads the page

Is there a way to tell how many frames are present, and select it depending if there is one of two??
enter8
Posts: 102
Joined: 05 May 2016, 16:48

Re: Frames and COM

08 Mar 2017, 16:26

There may be a better way, but you can get the number of frames with

document.parentWindow.frames.length
Crashm87
Posts: 48
Joined: 25 Jul 2016, 13:12

Re: Frames and COM

08 Mar 2017, 16:32

enter8 wrote:There may be a better way, but you can get the number of frames with

document.parentWindow.frames.length
Thank you, that helps alot.

Maybe I'll implement an IF statement and store number of frames in a variable.
enter8
Posts: 102
Joined: 05 May 2016, 16:48

Re: Frames and COM  Topic is solved

08 Mar 2017, 17:25

How about:

Code: Select all

framecount := document.parentWindow.frames.length
framecount -= 1 ; subtract 1 to get the right number of the array
myFrame := wb.document.parentWindow.frames[framecount].document.body.innerHTML
msgbox % myFrame
This will always target the last frame on the page. That's assuming, of course, your target frame is always last. If it isn't, you can turn off errors, and do queries on each frame until you find the one that has the information you want.
Crashm87
Posts: 48
Joined: 25 Jul 2016, 13:12

Re: Frames and COM

09 Mar 2017, 08:40

enter8 wrote:How about:

Code: Select all

framecount := document.parentWindow.frames.length
framecount -= 1 ; subtract 1 to get the right number of the array
myFrame := wb.document.parentWindow.frames[framecount].document.body.innerHTML
msgbox % myFrame
This will always target the last frame on the page. That's assuming, of course, your target frame is always last. If it isn't, you can turn off errors, and do queries on each frame until you find the one that has the information you want.
FANTASTIC! Thank you so much, that's a better idea than if statements.

What a great community.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], CoffeeChaton, Rohwedder, yxldh and 141 guests