Jump to content

Recommended Posts

Posted (edited)

In the past week, my script that I use to monitor and scrape an IE window was working fine. But lately, its been crashing for no reason in the middle of execution. The script is a while loop that refreshes the page every 15 secs, checks if I am logged in, and if a certain content exists. After like 15 min, it dies. When it dies I see a little tooltip bubble on IE's tab that says "Tab crashed and recovered by IE". This is the problem. I'm setting my $oIE to a particular instance, which crashes, and the new instance is unknown to the script.

So I had the idea to add a check for instance in my while loop. and if the original instance dies, I'd set it equal to the next instance it finds.

So I was trying this:

func _check_logged_in()
    ;## Log in if not logged in.
    $o_login = _IEGetObjByName(_checkOIE($oIE), "username")
.........
........
Endfunc

func _checkOIE(ByRef $oIE)
    $oDoc = _IEDocGetObj ($oIE)
    if @error > 0 Then
        $oIE = _IEAttach("", "instance" , 1)
    Else 
        $oIE = $oIE
    endif
    return $oIE
EndFunc

I don't think that is right.. but I'm not sure what I should do there. The error I get is:

ERROR: _IEGetObjByName() called with Const or expression on ByRef-param(s).
$o_login = _IEGetObjByName(_checkOIE($oIE), "username")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

any ideas?

Edited by DssTrainer
Posted

In the past week, my script that I use to monitor and scrape an IE window was working fine. But lately, its been crashing for no reason in the middle of execution. The script is a while loop that refreshes the page every 15 secs, checks if I am logged in, and if a certain content exists. After like 15 min, it dies. When it dies I see a little tooltip bubble on IE's tab that says "Tab crashed and recovered by IE". This is the problem. I'm setting my $oIE to a particular instance, which crashes, and the new instance is unknown to the script.

So I had the idea to add a check for instance in my while loop. and if the original instance dies, I'd set it equal to the next instance it finds.

So I was trying this:

func _check_logged_in()
;## Log in if not logged in.
    $o_login = _IEGetObjByName(_checkOIE($oIE), "username")
.........
........
Endfunc

func _checkOIE(ByRef $oIE)
    $oDoc = _IEDocGetObj ($oIE)
    if @error > 0 Then
        $oIE = _IEAttach("", "instance" , 1)
    Else 
        $oIE = $oIE
    endif
    return $oIE
EndFunc

I don't think that is right.. but I'm not sure what I should do there. The error I get is:

ERROR: _IEGetObjByName() called with Const or expression on ByRef-param(s).
$o_login = _IEGetObjByName(_checkOIE($oIE), "username")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

any ideas?

Don't nest the call to your _checkOIE() function, and since $oIE is passed ByRef to your function, there is no need to Return it:
Func _check_logged_in()
    _checkOIE($oIE)
    $o_login = _IEGetObjByName($oIE, "username")
Endfunc

Func _checkOIE(ByRef $oIE)
    $oDoc = _IEDocGetObj ($oIE)
    if @error Then
        $oIE = _IEAttach("", "instance" , 1)
    Else 
        $oIE = $oIE
    endif
EndFunc

:)

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
Posted

Well there are multiple steps...

check logged in

navigate to page

check for content

if content exists: goto this page, check this content

Loop

So if I only check the object at the top of the loop, then it might die in the middle somewhere. So that is why I wanted to nest the function, so it always gets the valid instance.

Posted

Well there are multiple steps...

check logged in

navigate to page

check for content

if content exists: goto this page, check this content

Loop

So if I only check the object at the top of the loop, then it might die in the middle somewhere. So that is why I wanted to nest the function, so it always gets the valid instance.

So, everywhere you have that one line, replace it with the two lines I showed you.

Keep in mind that if the page gets logged off and logged back in, or you have to re-navigate to it, then the object references to all the DOM elements will have changed, like for the login inputs.

:)

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
Posted (edited)

heh, yea I could put those 2 lines everywhere.. kinda defeats the purpose of a function :)

Cmon, this isn't qbasic!

Edited by DssTrainer
Posted

heh, yea I could put those 2 lines everywhere.. kinda defeats the purpose of a function :)

Cmon, this isn't qbasic!

Not exactly. What specific functions do you want to do this with? If it's just _IEGetObjByName() then you just code a wrapper function:
Func __IEGetObjByName(ByRef $oIE, $sName)
    Local $oDoc = _IEDocGetObj($oIE)
    If @error Then $oIE = _IEAttach("", "instance", 1)
    Return _IEGetObjByName($oIE, $sName)
EndFunc

Then you just use __IEGetObjByName() where you want to verify the $oIE object first.

:)

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