网上有个零网关切换工具
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <process.au3>
#include <Constants.au3>
#include <array.au3>
#include <GuiTab.au3>
#include <File.au3>
$g_szVersion = "IpChange"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)
$ipfile = @TempDir & "\ip.txt"
If FileExists(@TempDir & "\ip.txt") Then FileDelete(@TempDir & "\ip.txt")
RunWait(@ComSpec & " /c route print > " & $ipfile, "", @SW_HIDE)
$file = FileOpen($ipfile, 0)
$i = 1
Do
$Gatewaydq = FileReadLine($file, $i)
If @error = -1 Then ExitLoop
If StringInStr($Gatewaydq, "Default Gateway") = 0 Then
$i = $i + 1
$Gateway = ""
Else
$line1 = $i
$Gateway = StringTrimLeft(FileReadLine($file, $i), 18)
ExitLoop
EndIf
Until $i = 0
FileClose($file)
FileDelete($file)
;配置脚本检测
If Not FileExists(@ScriptDir & "\Proxy.ini") Then
MsgBox(64, "提示:", "未找到线路切换配置文件", 5) ;检查配置文件是否存在。
IniWrite(@ScriptDir & "\Proxy.ini", "Proxy", "示例格式", "192.168.1.1")
IniWrite(@ScriptDir & "\Proxy.ini", "Proxy", "线路二", "192.168.1.2")
ShellExecute("Notepad.exe", "Proxy.ini", @ScriptDir)
Exit
EndIf
If FileExists(@ScriptDir & "\Proxy.ini") Then
$Proxyfile = @ScriptDir & "\Proxy.ini"
$ProxyName = IniReadSection($Proxyfile, "Proxy")
If @error Then
MsgBox(4096, "", "发生错误,可能配置文件为非标准的配置文件.")
Else
For $p = 1 To $ProxyName[0][0]
;$Pno=$ProxyName[0][0]
;MsgBox(4096, "", "关键字:" & $ProxyName[$p][0] & @CRLF & "数值:" & $ProxyName[$p][1] & @crlf & "行数:"& $Pno)
Next
EndIf
EndIf
#Region ### START Koda GUI section ### Form=E:\AU3脚本程序\网关切换.kxf
$Form1 = GUICreate("零点技术联盟网络宽带线路切换工具V1.0", 378, 210, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("", 1, -5, 377, 215)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKHCENTER + $GUI_DOCKVCENTER + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$Group2 = GUICtrlCreateGroup("", 3, 2, 373, 65)
$Label1 = GUICtrlCreateLabel("注意:由于本工具采用了即时生效功能,所以在进行", 80, 25, 280, 17)
$Label2 = GUICtrlCreateLabel("网关地址切换时,上网会有延迟,这属正常现象。", 56, 41, 268, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label3 = GUICtrlCreateLabel("当前网关:", 72, 136, 65, 17)
GUICtrlSetFont(-1, 10, 400, 0, "宋体")
GUICtrlSetColor($Label3, 0xFF0000)
$Label4 = GUICtrlCreateLabel($Gateway, 130, 136, 120, 17)
$ip = GUICtrlCreateCombo($ProxyName[1][1], 230, 136, 120, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 10, 400, 0, "宋体")
GUICtrlSetColor($Label4, 0xFF0000)
$Label5 = GUICtrlCreateLabel("请在列表框中选择相应的上网线路:", 72, 80, 196, 17)
$name = GUICtrlCreateCombo($ProxyName[1][0], 120, 104, 145, 25)
$url = GUICtrlCreateLabel("网址:HTTP://Www.BiosClub.Com", 8, 176, 177, 17)
$Change = GUICtrlCreateButton("确定(&O)", 192, 168, 75, 25, 0)
$cancel = GUICtrlCreateButton("取消(&C)", 280, 168, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$Proxyfile1 = @ScriptDir & "\Proxy.ini"
$ProxyName1 = IniReadSection($Proxyfile1, "Proxy")
If @error Then
MsgBox(4096, "", "发生错误,可能配置文件为非标准的配置文件.")
Else
For $pp = 1 To $ProxyName1[0][0]
$varProxyName = GUICtrlSetData($name, $ProxyName1[$pp][0])
$varProxyIP = GUICtrlSetData($ip, $ProxyName1[$pp][1])
;MsgBox(4096, "", "关键字:" & $ProxyName[$p][0] & @CRLF & "数值:" & $ProxyName[$p][1] & @crlf & "行数:"& $Pno)
Next
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 500, "long", 0x00090000)
Exit
Case $name
$Proxyfile1 = @ScriptDir & "\Proxy.ini"
$ProxyName1 = IniReadSection($Proxyfile1, "Proxy")
For $pp = 1 To $ProxyName1[0][0]
$getname = GUICtrlRead($name)
If $getname = $ProxyName1[$pp][0] Then GUICtrlSetData($ip, $ProxyName1[$pp][1])
$getip = GUICtrlRead($ip)
Next
Case $url
ShellExecute("iexplore.exe", "http://www.biosclub.com")
Case $Change
$getip = GUICtrlRead($ip)
$getname = GUICtrlRead($name)
If $getip = "" Then $getip = $ProxyName1[1][1]
$dosrun = "route add 0.0.0.0 mask 0.0.0.0 " & $getip
_RunDOS("route delete 0.0.0.0")
_RunDOS($dosrun)
RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions", "NoSelectDownloadDir", "REG_DWORD", "0")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", "1803", "REG_DWORD", "0")
MsgBox(0, "切换下载线路成功", "你现在已经切换到" & $getname)
Exit
Case $cancel
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 500, "long", 0x00090000)
Exit
EndSwitch
WEnd
|