Sign in to follow this  
Followers 0
cassetti

Assigning object to a new popup window

7 posts in this topic

Ok - so i really am a newbie to this whole COM and objects - even to this program lol!

(i know i know - people here to help shiver when they hear that)

I'm trying to automate the logging in of a webpage - and clicking through the links.

since there is sensitive material in the script - i can't give out the whole code. I did use part of the code i found on this topic:

http://www.autoitscript.com/forum/index.ph...pic=12641&st=15

Basically - i have the script working - it works fine at logging in and clicking through the links. the only problem is - that i have a few more things to click after one link - but the new link opens up a new internet explorer window.

Here is the code i took from that other forum - that is working great so far:

Func clickLink($obj, $searchText, $instance = 1)
; clickLink( $obj, $serachText [, $instance])
; $obj - Object Valiable pointing to an InternetExplorer.Application object
; $searchText - the text displayed on the web page for the desired link to click
; [$instance] - if the link text occurs more than once, specify which instance you want to click (numbering starts at 1)
   $doc = $obj.document
   $links = $doc.links
   $found = 0
   For $link in $links
      $linkText = $link.outerText
      If StringInStr($linkText, $searchText) Then
         $found = $found + 1
         if ($found = $instance) Then
            $result = $link.click
            ExitLoop
         EndIf
      EndIf
   Next
  
EndFunc;==>clickLink

I made this one up really fast to shorten code:

Func PauseWhileLoading($obj2)
        with $obj2
           While .Busy
              Sleep(50)
           WEnd     
        EndWith
    Sleep(500)
EndFunc; ==>PauseWhileLoading

Now heere is where the problem is

PauseWhileLoading($ObjIE)

clickLink($ObjIE, "Management")

PauseWhileLoading($ObjIE)

$objIE2 = objcreate(clickLink($ObjIE, "Administration")

The first clickLink works - because that is still using the same page

Then when you click on the link on the page to "Administration" - a new window pops up - i need to automate clicking links on the popup - but can't figure out how the heck to associate the new window with $objIE2 (which is what i'm calling the new window - or wnat to call it anyways)

thanks guys for any help i can get - and expect to see a donation from me to this program - it is an AWESOME program that is making my life a LOT easier!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'd suggest you get the UDF library I'm working on here:IE Automation UDF Library

Then I think you should be able to adapt the following code to work:

#include <IE.au3>

; Note that _IENavigtate() and _IEClickLinkByText() call _IELoadWait() by default

$ObjIE = _IECreate()
_IENavigate($ObjIE, "your url")
_IEClickLinkByText($ObjIE, "Management")

; you may need to Sleep(xxx miliseconds)
$ObjIE2 = _IEAttach("Title of new window", "Title")
_IELoadWait($ObjIE2)
_IEClickLinkByText($ObjIE2, "Administration")

Edit: Added comment to sameple code about functions calling _IELoadWait()

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi - sorry to be a bother - But it seems as though i am still running into issues.

I redid my script so far - so that i did use the IE.au3 Library - it works great (can't wait to use the other featuers!)

But i am running into an issue with the $objIE2 - something is screwed up - the program gives an error right after the new IE window pops up.

Here is the code I typed - It should work - considering i copied and pasted directly into the notepad the title of the window......

$ObjIE2 = _IEAttach("Store Administration", "Title")

_IELoadWait($ObjIE2)

_IEClickLinkByText($ObjIE2, "Support")

Thanks again for your help!

Edited by cassetti

Share this post


Link to post
Share on other sites

Ok - it looks like it is not creating an object when it puts in the $objIE2

maybe its not the right command? i'm goign to try and look at the other functions in the library, see what i can come up wtih.

Share this post


Link to post
Share on other sites

:)

Wow - i feel like an idiot - after spending 2 hours total screwing around with various possible solutions - i finally figured it out!

lol - its so simple i feel so dumb.

i inserted a

sleep(1000)

$objIE2 = _ieattach("blahblahbl

:evil:

Share this post


Link to post
Share on other sites

Yeah, sorry -- you need to give the window a chance to initialize before you look for it. I put that suggestion into a comment in the sample code, but didn't actually include the Sleep command for you.

Glad you have it working.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

oh my god - i love this program - it saves me about 10 minutes of clicking and navigating.

now - a process for my boss that would have taken a good 20 minutes total to do - is now done with the click of one button so anyone in our small company can do it!

(i am definately going to have my boss make a donation to this program - while not big since we are a small company - there are a lot of uses for this utility!)

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  
Followers 0