切换网关的小工具(AutoIT3编写,仅供参考)
---记录一下编写过程
1.采用AutoIT3中的工具KODA图形工具编辑需要的图形界面,然后再生成onevent模式(相关模式可参考autoit3帮助文件)的au3脚本
2.在au3脚本中根据事件添加相应事件过程
难点:
1.检查Rodia单选控件是否选中状态,BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED),用此语句就行,同样可用在复选框、Listview 、Treeview 等项目
具体脚本如下:
- #Region ;**** 参数创建于 ACNWrapper_GUI ****
- #PRE_icon=C:\windows\syswow64\SHELL32.dll|-136
- #PRE_U***64=n
- #PRE_Res_requestedExecutionLevel=None
- #AutoIt3Wrapper_Run_Debug_Mode=Y
- #EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
- #include
- #include
- #include
- Opt("GUIOnEventMode", 1)
- Local $Form1_1,$Radio1,$Radio2,$Button1
- #Region ### START Koda GUI section ### Form=setroute.kxf
- $Form1_1 = GUICreate("网关切换", 195, 114, 192, 124)
- GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close")
- GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1_1Minimize")
- GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1_1Maximize")
- GUISetOnEvent($GUI_EVENT_RESTORE, "Form1_1Restore")
- $Button1 = GUICtrlCreateButton("OK", 112, 80, 75, 25)
- GUICtrlSetFont($Button1, 12, 800, 0, "宋体")
- GUICtrlSetOnEvent($Button1, "Button1Click")
- $Radio1 = GUICtrlCreateRadio("10.1.10.8", 39, 17, 113, 17)
- GUICtrlSetState($Radio1, $GUI_CHECKED)
- GUICtrlSetFont($Radio1, 12, 800, 0, "宋体")
- GUICtrlSetOnEvent($Radio1, "Radio1Click")
- $Radio2 = GUICtrlCreateRadio("10.1.10.236", 39, 49, 121, 17)
- GUICtrlSetFont($Radio2, 12, 800, 0, "宋体")
- GUICtrlSetOnEvent($Radio2, "Radio2Click")
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- While 1
- Sleep(100)
- WEnd
- Func Button1Click()
- Run(@ComSpec & ' /c route delete 0.0.0.0',"", @SW_HIDE)
- If BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
- Run(@ComSpec & ' /c route add 0.0.0.0 mask 0.0.0.0 10.1.10.8',"", @SW_HIDE)
- MsgBox(4096,"网关设置","设置网关8成功")
- Else
- Run(@ComSpec & ' /c route add 0.0.0.0 mask 0.0.0.0 10.1.10.236',"", @SW_HIDE)
- MsgBox(4096,"网关设置","设置网关236成功")
- EndIf
- EndFunc
- Func Radio()
-
- EndFunc
- Func Form1_1Close()
- Exit
- EndFunc
- Func Form1_1Maximize()
- EndFunc
- Func Form1_1Minimize()
- EndFunc
- Func Form1_1Restore()
- EndFunc
- Func Radio1Click()
- GUICtrlSetState($Radio1,$GUI_CHECKED)
- EndFunc
- Func Radio2Click()
- GUICtrlSetState($Radio2,$GUI_CHECKED)
- EndFunc
阅读(3102) | 评论(0) | 转发(0) |