Jump to content
Sign in to follow this  
killerofsix

IE One instance, two windows

Recommended Posts

killerofsix

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

Share this post


Link to post
Share on other sites
dragan

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

Share this post


Link to post
Share on other sites
Chimp

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


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

Share this post


Link to post
Share on other sites
killerofsix

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

Share this post


Link to post
Share on other sites
Chimp

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

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

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
    • SkysLastChance
      By SkysLastChance
      I am trying to grab the id "in2xk_26" however it the characters before the underscore always change. (in the name too)
      Is there a way I can find a id or name by the last 3 charcters?
      Using something like "stringright?"
      So I would want to search for just "_26" in this case.
      This is assuming that there are no other _26
       

      #include <Excel.au3> #include <IE.au3> #include <GUIConstantsEx.au3> Global $iMousespeed = 25,$target = "",$TagName = "",$Value = "",$Atrribute = "" $oIE = _IEAttach("MEDITECH") $TagName = "input" $Value = "in2xk_26" $Attribute = "id" $tags = $oIE.document.GetElementsByTagName($TagName) ;TagName ------ MAKE SURE TO NAME THESE For $tag in $tags $class_value = $tag.GetAttribute($Attribute) ;Attribute ------ MAKE SURE TO NAME THESE If string($class_value) = $Value Then ;Value ------ MAKE SURE TO NAME THESE $target = $tag $iScreenX = _IEPropertyGet($target, "screenx") $iScreenY = _IEPropertyGet($target, "screeny") $iWidth = _IEPropertyGet($target, "width") $iHeight = _IEPropertyGet($target, "height") $oMouseCords = MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed) MouseClick($MOUSE_CLICK_LEFT) ExitLoop EndIf Next  
       
    • SkysLastChance
      By SkysLastChance
      I was wondering how I read data inside of a iframe. I would like to be able to click something inside a iframe. However, I can't even find the tag. 
      The id and name change all the time so I can't use those. 
      The code highlighted in blue is what I am trying to click. (second picture)
      Here is what I have tried.
      $target = "" $tags = $oIE.document.GetElementsByTagName("div") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "s_92 altstyle s_93 s_94" Then $target = $tag ConsoleWrite("Tag Found " & $target.outerText&@CRLF) ExitLoop EndIf Next  

       
       

    • SkysLastChance
      By SkysLastChance
       
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?
       

    • SkysLastChance
      By SkysLastChance
      I am trying to type a name in patient summary search box. How should I go about doing this. I am clearly not doing it right. (Attached Picture of HTML code.)
      This is what I have tried. I assume this is not working because it is not a form? 
      WinActivate("MEDITECH - Internet Explorer")       Sleep (500)    $oIE = _IEAttach("MEDITECH")    $oForm = _IEFormGetObjByName($oIE, "systemMenu")    $oText = _IEFormElementGetObjByName($oForm, "sysmenu-searchbarinput") _IEFormElementSetValue($oText, "Hey! This works!")
×