Sign in to follow this  
Followers 0
SubZer0

Objectvariable not usable after first if run

3 posts in this topic

Hi there,

got the following code:

#include <IE.au3>

$IE = _IECreate("xxx")
$links = _IELinkGetCollection($IE)
$numlinks = @extended
For $link in $links
    if StringInStr($link.href,"fc.php") <> 0 Then
        $tan = StringRight($link.href,32)
        $url = StringFormat("xxx",$tan)
        _IENavigate($IE,$url)
    EndIf
Next

The run through the For loop works fine till when the first time the if statement is called. First time if statement works fine too but after the if statement has finished executing and the next for loop starts i am not able to access link.href (Displayed error: The requested action with this object has failed). Somebody knows why that is so?

greetz & thx 4 help

Share this post


Link to post
Share on other sites



Hi there,

got the following code:

#include <IE.au3>

$IE = _IECreate("xxx")
$links = _IELinkGetCollection($IE)
$numlinks = @extended
For $link in $links
    if StringInStr($link.href,"fc.php") <> 0 Then
        $tan = StringRight($link.href,32)
        $url = StringFormat("xxx",$tan)
        _IENavigate($IE,$url)
    EndIf
Next

The run through the For loop works fine till when the first time the if statement is called. First time if statement works fine too but after the if statement has finished executing and the next for loop starts i am not able to access link.href (Displayed error: The requested action with this object has failed). Somebody knows why that is so?

greetz & thx 4 help

Your variable $links is a collection object, containing pointers to the link objects (not actual copies of the links). When you execute _IENavigate() to a different page, all those objects become invalid. To do what you are trying (follow every link) you'll have to have a different $IE object for each one, or at least open a new tab for each (if IE7).

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Ahh thx that was my error in reasoning :whistle:

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