#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\tools\ICO\The Icons\Network.ico
#AutoIt3Wrapper_outfile=urltz.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#NoTrayIcon
#include<IE.au3>
Opt("MustDeclareVars",1)
;au3监控IE地址栏网址自动路转
Global $ConfigFile = @ScriptDir & "\urltz.ini"
Global $CurrentURL,$SourceUrls,$TargetURL
Global $DefaultTargetURL = "http://www.hao123.com"
Dim $MyVersion = "au3urltz"
If WinExists($MyVersion) Then Exit
AutoItWinSetTitle($MyVersion)
HotKeySet("#{F9}","_Exit") ;设置全局快捷键(Windows徽标键+F9退出程序)
$SourceUrls = IniReadSection($ConfigFile,"SourceURL")
$TargetURL = IniRead($ConfigFile,"TargetURL","TargetURL",$DefaultTargetURL)
While 1
Sleep(300)
;;;=======================================================
;;;得到所有IE窗口
Dim $IE_Objects[1],$i = 1,$n,$x, $oIE
$IE_Objects[0] = 0
While 1
$oIE = _IEAttach ("", "instance", $i)
If @error = $_IEStatus_NoMatch Then ExitLoop
ReDim $IE_Objects[$i + 1]
$IE_Objects[$i] = $oIE
$IE_Objects[0] = $i
$i += 1
WEnd
;MsgBox(0,"",$IE_Objects[0])
;;;========================================================
For $n=1 To $IE_Objects[0]
$CurrentURL = _IEPropertyGet($IE_Objects[$n],"locationurl")
;MsgBox(0,"",$CurrentURL)
For $x = 1 To $SourceUrls[0][0]
If $CurrentURL=$SourceUrls[$x][1] or $CurrentURL=$SourceUrls[$x][1] & "/" Then _IENavigate($IE_Objects[$n],$TargetURL)
Next
Next
WEnd
Func _Exit()
Exit
EndFunc
|