Global $__obj_Error = 0, $__obj_Event = ObjEvent('AutoIt.Error', '__com_getError')
Func _GUIHtml_SetEvent($hObj, $sHtmlFor, $sEvent, $sScript)
Local $oScript = $hObj.document.CreateElement('script')
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 1, 0)
EndIf
With $oScript
.Defer = True
.Language = 'jscript'
.Type = 'text/javascript'
.HtmlFor = $sHtmlFor
.Event = $sEvent
.Text = $sScript
EndWith
$hObj.document.all.tags('head').Item(0).AppendChild($oScript)
If $__obj_Error Then
$__obj_Error = 0
Return SetError(1, 2, 0)
EndIf
Return 1
EndFunc
Func __com_getError()
$__obj_Error = $__obj_Event.Number
EndFunc
...
_GUIHtml_SetEvent($oIE, 'document', 'oncontextmenu', 'return false')