Sign in to follow this  
Followers 0
continyu

Fail stringinstr function.

2 posts in this topic

#1 ·  Posted (edited)

Hi there, this code runs at first time but fails in second...

$oIE = _IECreate("www.somesite.com")

$oLinks = _IELinkGetCollection($oIE)
For $oLink In   $oLinks
Sleep(1000)
    $findlink = StringInStr($oLink.href, "http://www.somesite.com/some.php?")
    If $findlink = 0 Then
        Sleep(10)
    Else
        _IEAction($oLink,"click")
        MsgBox(0,"click","done")
_IENavigate($oIE,$oLink)
    $add = _IEGetObjByName($oIE,"add")
_IELinkClickByText($oIE,"[ Add a personal message ]")
        $pmsgform = _IEFormGetCollection($oIE,6)
    $pmsgbox = _IEFormElementGetObjByName($pmsgform,"message")
    _IEFormElementSetValue($pmsgbox,$pmsg)
    _IEAction($add,"click")
    _IELoadWait($oIE)
    _IENavigate($oIE,"www.somesite.com")
    _IELoadWait($oIE)
    $oLinks = _IELinkGetCollection($oIE)
    EndIf
Next

I get this error from console

(34) : ==> The requested action with this object has failed.:

line 34 is $findlink = StringInStr($oLink.href, "http://www.somesite.com/some.php?")

Is there something wrong in principle or it's something about site?

Edited by continyu

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you navigate IE at all, the object references become invalid ($oIE, $oForm, $oLinks, $oLink, etc.). If you want to make some use of the links on a page, do it in a separate instance (or tab), or get a collection of all the href strings saved off before you start navigating them.

:blink:

Edit: $oIE is not invalidated, but everything else under it is. ;)

Edited by PsaltyDS

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

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