软件作用
代码分享
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Process.au3>
#RequireAdmin
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate(“IP修改器”, 367, 84, 289, 241);定义标题与窗口大小
GUISetBkColor(0xd1f6c1, $Form1)
$Input1 = GUICtrlCreateInput(“”, 8, 45, 257, 18, BitOR($ES_CENTER, $ES_NUMBER));定义输入框,文本居中和只能输入数字!
GUICtrlCreateLabel(“输入IP的最后一位(1-54)”, -1, 15, “”, “”)
$Button1 = GUICtrlCreateButton(“确定”, 280, 41, 75, 25, $BS_DEFPUSHBUTTON);定义按钮样式按enter键确认
GUISetState(@SW_SHOW);设置显示窗口
#EndRegion ### END Koda GUI section ###
$dns = “10.71.0.11”;定义首选DNS的值
$bak_dns = “202.96.128.166”;定义备选DNS的值
While 1
$nMsg = GUIGetMsg();定义窗口一直显示
Switch $nMsg
Case $GUI_EVENT_CLOSE;定义当按下右上的关闭按钮。
Exit
Case $Button1;定义当按下按钮1时
If GUICtrlRead($Input1) >= 55 Then;判断是否大于54,大于就提示并停止执行。
MsgBox($MB_SYSTEMMODAL, “叼7你啦”, “可唔可以唔好输大于54噶”)
ControlSetText(“IP修改器”,””,””,””);清空文本框内容
Else
RunWait(‘netsh interface ip set dns name = “本地连接” source = static addr = ‘ & $dns & ‘ register = PRIMARY’, “c:\windows\system32”, @SW_HIDE)
RunWait(‘netsh interface ip add dns name = “本地连接” addr = ‘ & $bak_dns & ‘ index=2’, “c:\windows\system32”, @SW_HIDE)
MsgBox($MB_SYSTEMMODAL, “搞掂啦”, “搞掂啦柒头”, 3)
ExitLoop
EndIf
EndSwitch
WEnd
成品图
出错图
成功图
完成图