Sign in to follow this  
Followers 0
danrche

_IE.au3 Help with Error Handling

5 posts in this topic

Hello All,

I'm trying to figure out how to handle errors with this code, and in general. I've read a bit on the references and welcome any other sources that would help. Here's my issue, the below code works most of the time, but sometimes it gives "Return SetError($_IEStatus_Success, 0, $o_object.document.body.innerText)" Error stating Variable must be of type "Object". What's the best practice method for error handling?

Code for review:

#comments-start

Created to alert for off-line servers from RMM tool, will later build in escape functions to exit the loop. End result should be every 1 min to check for off-line Servers and speak them outloud. This is for the most part for me to learn how to code.

#comments-end

#include <IE.au3>

$quit = 0

While $quit = 0

_Test()

Sleep(100)

WEnd

Func _Test()

$oIE = _IECreate("http://my RMM tool website here")

$frames = _IEFrameGetCollection($oIE);

$numFrames = @extended ; number of frames

If @error Then

_IEQuit($oIE)

EndIf

For $i = 0 to ($numFrames -1)

$oFrame = _IEFrameGetCollection($oIE, $i)

$xi = _IEBodyReadText($oFrame)

$myArray = StringSplit($xi, @CR , 2)

For $g In $myArray

If StringInStr($g, "offline", 0) <> 0 Then

$t = StringTrimLeft($g, 23)

_IEQuit($oIE)

_talk($t)

EndIF

Next

Next

EndFunc

Func _talk($sText)

AutoItSetOption("RunErrorsFatal",0)

SoundSetWaveVolume(100)

$WshShell = ObjCreate("SAPI.spVoice")

$WshShell.Speak ($sText)

EndFunc

Share this post


Link to post
Share on other sites



Suggest you simply add _IELoadWait($oFrame) into your code just prior to the _IEBodyReadText call.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Verify $oFrame is valid with with IsObj($oFrame) before you try "$xi = _IEBodyReadText($oFrame)".

:)

Edit: Ooh, good idea from Dale while I was typing...

:)

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

Verify $oFrame is valid with with IsObj($oFrame) before you try "$xi = _IEBodyReadText($oFrame)".

:)

Awesome, thanks guys, I'll give that a try. Thanks for pointing me in the right direction. :)

Share this post


Link to post
Share on other sites

Awesome, thanks guys, I'll give that a try. Thanks for pointing me in the right direction. :)

YES!!! IT WORKS!!! Thanks again guys, I used the _IELoadWait($oFrame) suggestion and it clicks evertime now. now I can get busy on building this in as an app with systray and escape keys.

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