Jump to content

Recommended Posts

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...