Opened on Nov 16, 2015 at 8:16:12 AM
Closed on Jun 11, 2021 at 1:17:48 PM
Last modified on Mar 29, 2026 at 3:35:17 PM
#3167 closed Bug (Fixed)
COM Error Handler - not always fires event — at Version 7
| Reported by: | mLipok | Owned by: | Jon |
|---|---|---|---|
| Milestone: | 3.3.15.4 | Component: | AutoIt |
| Version: | 3.3.15.0 | Severity: | None |
| Keywords: | Cc: |
Description (last modified by )
Discussion:
https://www.autoitscript.com/forum/topic/178424-com-error-handler-not-working-for-some-strange-reason/
Here is reproducer:
; Initialize COM error handler $oErrorHandler = ObjEvent("AutoIt.Error", _ErrFunc) Func _ErrFunc($oError) ConsoleWrite("!ERROR caught" & @CRLF) EndFunc ; Create shell object $oObj = ObjCreate("shell.application") ;The following line should trigger COM error handler (at the last dot). $oObj.Windows().Item(666).bzzzzzzz
Here are some of my test results:
;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3.3.8.1\ ; NOTHING ;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_10_2\ ; !ERROR caught ;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_12_0\ ; !ERROR caught ;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_13_12\ ; NOTHING ;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_13_15\ ; BUG/ISSUE EXIST ;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_13_19\ ; BUG/ISSUE EXIST ;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3.3.15.0\ ; BUG/ISSUE EXIST ;~ #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\AutoIt_3_3_18_0\ ; !ERROR caught
Change History (7)
comment:1 by , on Nov 16, 2015 at 8:17:02 AM
| Description: | modified (diff) |
|---|
comment:3 by , on Nov 30, 2015 at 8:54:13 PM
For reference
Link to other discussion in MVP forum:
https://www.autoitscript.com/forum/topic/176064-excel-com-error-handler-problem/
comment:4 by , on Aug 11, 2020 at 12:32:06 PM
| Owner: | set to |
|---|---|
| Status: | new → assigned |
Hi,
FIx sent to Jon
comment:6 by , on Jun 11, 2021 at 1:17:48 PM
| Milestone: | → 3.3.15.4 |
|---|---|
| Owner: | changed from to |
| Resolution: | → Fixed |
| Status: | assigned → closed |
Fixed by revision [12553] in version: 3.3.15.4
comment:7 by , on Mar 29, 2026 at 3:35:17 PM
| Description: | modified (diff) |
|---|
Note:
See TracTickets
for help on using tickets.

In fact
In fact it was OK even with the reference to an unknown function in 3.3.10 till 3.3.13.6
3.3.13.7 reintroduce the no detection as 3.3.8.1
Example() Func Example() ; Error monitoring. This will trap all COM errors while alive. ; This particular object is declared as local, meaning after the function returns it will not exist. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") #forceref $oErrorHandler ; Create shell object Local $oObj = ObjCreate("shell.application") ;The following line trigger COM error handler. $oObj.InvalidFunction() If @error Then ConsoleWrite("+COM Error Detected @error=0x" & Hex(@error) & @CRLF) Else ConsoleWrite("!COM Error Not Detected" & @CRLF) EndIf ;The following line should trigger COM error handler (at the last dot). $oObj.Windows().Item(666).bzzzzzzz If @error Then ConsoleWrite("+COM Error Detected @error=0x" & Hex(@error) & @CRLF) Else ConsoleWrite("!COM Error Not Detected" & @CRLF) EndIf EndFunc ;==>Example Func _ErrFunc($oError) ;~ #forceref $oError ConsoleWrite("+ERROR caught at ligne " & $oError.scriptline & " : " & StringTrimRight($oError.windescription, 2) & @CRLF) ;~ ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ ;~ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ ;~ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ ;~ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ ;~ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ ;~ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ ;~ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ ;~ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ ;~ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ ;~ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc