WildCrosssing Posted November 24, 2006 Share Posted November 24, 2006 Ok, sometime, I have some error with COM object and when it happens, my autoit crash. How can I make silent error? If the COM object failed, it runs the line below without terminate the script and say an error message. How? Thanks. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 24, 2006 Share Posted November 24, 2006 Ok, sometime, I have some error with COM object and when it happens, my autoit crash. How can I make silent error? If the COM object failed, it runs the line below without terminate the script and say an error message. How? Thanks. When your script throws a COM error, you must have already defined a function to handle it. Read the Obj/COM Reference section of the help file, especialy down at the subsection titled "COM Error Handling". With help from several smarter people than me on this forum, I have settled on the following: $oComError = ObjEvent("AutoIt.Error","_ComErrFunc") ; Install a custom error handler ; The rest of your script, which may throw COM errors... ;-------------------------------------- ; Function _ComErrFunc() ; Custom COM object error handler ;-------------------------------------- Func _ComErrFunc() Local $HexNumber = Hex($oComError.number, 8) MsgBox(16, "AutoIT COM Error", "AutoIT COM Error Occured!" & @CRLF & _ @TAB & "Error Number: " & $HexNumber & @CRLF & _ @TAB & "Line Number: " & $oComError.scriptline & @CRLF & _ @TAB & "Description: " & $oComError.description & @CRLF & _ @TAB & "WinDescription: " & $oComError.windescription) SetError(1); something to check for when this function returns EndFunc ;==>_ComErrFunc Hope that helps. 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now