$Query.name出错的问题
在程序中使用$Query.name有时会出错,如以下程序: For $Form In $oForms$oQuerys = _IEFormElementGetCollection($Form)
For $Query In $oQuerys
FileWrite("IE_TEST.TXT", @CRLF & "表单控件信息:" & @CRLF & "名称:" & $Query.name & " 类型:" & $Query.type & @CRLF)
Next
NextAutoIt在很多情况下,出错就直接退出了,不知有什么办法能够避免这种情况,出错后不要退出,捕捉到错误信息后再处理
不知AutoIt 能不能实现Try ... Catch 这样的语句? 好象不可以啊.这个不是C#啊..哈哈 本帖最后由 passkalilo 于 2009-6-19 00:51 编辑
找到解决方法了,官网有人给的回复:
Global $g_eventerror = 0 ; to be checked to know if com error occurs. Must be reset after handling.
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler
; This is my custom error handler
Func MyErrFunc()
Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF& @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & hex($oMyError.number,8)& @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
)
Local $err = $oMyError.number
If $err = 0 Then $err = -1
$g_eventerror = $err; to check for after this function returns
EndFunc ;==>MyErrFunc 楼上这个东东有时挺有用,收下以备后用! 同求,感谢3楼楼主. 混在成都网 看不懂,但还是顶了
页:
[1]