Sign in to follow this  
Followers 0

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("")

$oLinks = _IELinkGetCollection($oIE)
For $oLink In   $oLinks
    $findlink = StringInStr($oLink.href, "")
    If $findlink = 0 Then
    $add = _IEGetObjByName($oIE,"add")
_IELinkClickByText($oIE,"[ Add a personal message ]")
        $pmsgform = _IEFormGetCollection($oIE,6)
    $pmsgbox = _IEFormElementGetObjByName($pmsgform,"message")
    $oLinks = _IELinkGetCollection($oIE)

I get this error from console

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

line 34 is $findlink = StringInStr($oLink.href, "")

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.


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