Jump to content

IE One instance, two windows


Go to solution Solved by Gianni,

Recommended Posts

I have a feeling this is really simple yet somehow I haven't been able to get it.

Basically I _iecreate("http://randwebportal.com/) a new window and enter some info into a form and submit it. Once the new page has loaded I click on a link that opens a child window where I'll be doing some more automation. This second window is part of the same instance as the first one I made. What I can't figure out how to do is get the ie.application object of this new child window. I tried using WinGetHandle() which didn't work. I tried referring back to the original ie object to perform other _ieXX functions, didn't work either.

This second window is opened with a javascript function on the webpage. It also becomes the active window.

Thanks for any help.

 

Add a 

_IELoadWait($oIE2)

after the Do..Until loop

Do
    Sleep(250)
    Local $oIE2 = _IEAttach("Title of the popup window", "embedded")
Until IsObj($oIE2)
_IELoadWait($oIE2)
Edited by killerofsix

"The quieter you are, the more you are able to hear..."

My AppsUSB Finder

Link to comment
Share on other sites

command:

_IEAttach

check it out in the help files, there are various ways to gain control over other IE windows.
 
 

If you don't need the first instance anymore, and you need only 2nd one (the one that pops-up), then I would suggest that you invoke the javascript function so that it no longer uses "_blank" targeting attribute. That way, it would open new URL in that same IE instance you already started, OR extract URL from javascript function, and navigate to that URL in the first IE instance.

Edited by dragan
Link to comment
Share on other sites

  • Solution

Hi killerofsix
you could try with a new _IEAttach instead of WinGetHandle, it worked for me.
something like this:

Do
    Sleep(250)
    Local $oIE2 = _IEAttach("Title of the popup window", "embedded")
Until IsObj($oIE2)

bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Thanks guys. For some reason using _IEAttach wasn't working for me when I was first using it. Revisited since you two mentioned it. I have it working now so thanks :)

EDIT: Also have to use sleep(1000) as I discovered through this topic '?do=embed' frameborder='0' data-embedContent>>

The script won't run if sleep is <1000

Edited by killerofsix

"The quieter you are, the more you are able to hear..."

My AppsUSB Finder

Link to comment
Share on other sites

in fact,

in my original script there are this two additional lines :).

Do
    Sleep(250)
    Local $oIE2 = _IEAttach("Title of the popup window", "embedded")
Until IsObj($oIE2)

_IELoadWait($oIE2) ; ??? this seems to have no effect.

Sleep(2000) ; workaround to give time to page to be ready

bye

EDIT:

Reading the link of the topic you provided,  >in this post Mr. DaleHohm suggest to use _IEDocReadHTML to read the HTML source of the document and maybe wait until it contains a known specific tag so to be sure that the page has finished to load.
maybe it should be a better solution instead the use of Sleep() but it should be experimented case by case.

Edited by Pincopanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...