Ticket #1108: IPChangerV2.x.au3

File IPChangerV2.x.au3, 42.4 KB (added by anonymous, 12 years ago)
Line 
1#include <GuiConstants.au3>
2
3Opt("TrayMenuMode",1)
4
5Global $version = "Version 1.88 TLC"
6Global $WinTitle = "Fast IP Changer (" & $version & ") - LCTan - written in AutoIT"
7Global $SettingsFile = @ScriptDir & "\Settings.ini"
8Global $DefaultWelcome = 0
9Global $WelcomeMSG = "Fast IP Changer (" & $version & ")" & @CRLF & "written and designed by LCTan" & @CRLF & @CRLF & "special thanks go to anyone and everyone who has used this and supplied input."
10Global $WelcomeWarning = @CRLF & @CRLF & "*****WARNING*****" & @CRLF & "This program is designed to be used by personel who administrate LAN's and have a fair understanding of the Network addressing sceme's of their networks." & @CRLF & "Using this program incorrectly may stop your computer from accessing or being accessed by the network." & @CRLF & "This also means that you may loose internet connection."
11Global $WelcomeExtra = @CRLF & @CRLF & 'This message can be removed in the settings.ini file and changing the "Welcome MSG" option to "0"'
12Global $DefaultDebug = 0
13
14Global $DefautTab1Name = "Config 1"
15Global $DefautTab2Name = "Config 2"
16Global $DefautTab3Name = "Config 3"
17Global $DefautTab4Name = "Config 4"
18Global $DefautTab4Name = "Config 5"
19
20Global $Adapters, $Adapter3
21Global $DefaultGW = ""
22Global $IPaddress = ""
23Global $Subnet = ""
24Global $DHCP = ""
25Global $Mark = 0
26
27$check1 = 0
28$check2 = 0
29$check3 = 0
30$check4 = 0
31
32$wbemFlagReturnImmediately = 0x10
33$wbemFlagForwardOnly = 0x20
34$colItems1 = ""
35$colItems2 = ""
36
37$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
38
39$GUI = GuiCreate ($WinTitle, 700, 300, -1, -1)
40$statuslabel = GUICtrlCreateLabel ("",1,280,698,19,BitOr($SS_SIMPLE,$SS_SUNKEN))
41
42GUICtrlCreateLabel("Network Adapter: ", 10, 15)
43
44If IniRead($SettingsFile, "Program Options", "Welcome MSG" , $DefaultWelcome) = 1 Then
45        Global $WelcomeEnable = 1
46Else
47        Global $WelcomeEnable = 0
48EndIf
49
50If IniRead($SettingsFile, "Program Options", "Debug", $DefaultDebug) = 1 Then
51        Global $show = @SW_SHOW
52Else
53        Global $show = @SW_HIDE
54EndIf
55
56$NoteXPos = 8
57$NoteYPos = 257
58$NoteString1 = "Note: IP Change Failed, Please Check settings (and cable?)"
59$NoteString2 = "Note: No IP detected please check cable/connection"
60$NoteString3 = "Note: No adapters detected, please check system config"
61$NoteString4 = "IP Changed successfully"
62$NoteString5 = "Please make sure you have selected your adapter"
63$NoteString6 = "Failed to get IP via DHCP, make sure you are connected to a DHCP server."
64$NoteString7 = "Failed to set DNS server (settings might still work)"
65
66If $WelcomeEnable = 1 Then MsgBox(0,$WinTitle,$WelcomeMSG & $WelcomeWarning & $WelcomeExtra)
67
68$Lab1Pos1 = 105 ;left position of the stats label
69$Lab1Pos2 = 55 ;top position of the stats label
70GUICtrlCreateGroup("", $Lab1Pos1, $Lab1Pos2, 190, 156)
71$Lab1Pos1 = $Lab1Pos1 + 8
72$Lab1Pos2 = $Lab1Pos2 + 13
73GUICtrlCreateLabel("IP Address: ", $Lab1Pos1, $Lab1Pos2)
74$Lab1Pos2 = $Lab1Pos2 + 20
75GUICtrlCreateLabel("Subnet Mask: ", $Lab1Pos1, $Lab1Pos2)
76$Lab1Pos2 = $Lab1Pos2 + 20
77GUICtrlCreateLabel("Default GW: ", $Lab1Pos1, $Lab1Pos2)
78$Lab1Pos2 = $Lab1Pos2 + 20
79GUICtrlCreateLabel("Pri DNS Server: ", $Lab1Pos1, $Lab1Pos2)
80$Lab1Pos2 = $Lab1Pos2 + 20
81GUICtrlCreateLabel("Pri WINS Server: ", $Lab1Pos1, $Lab1Pos2)
82$Lab1Pos2 = $Lab1Pos2 + 20
83GUICtrlCreateLabel("DHCP Enabled: ", $Lab1Pos1, $Lab1Pos2)
84$Lab1Pos2 = $Lab1Pos2 + 20
85GUICtrlCreateLabel("DHCP Server: ", $Lab1Pos1, $Lab1Pos2)
86$Lab1Pos1 = $Lab1Pos1 + 85
87$Lab1Pos2 = $Lab1Pos2 - 120
88$label1 = GUICtrlCreateLabel("", $Lab1Pos1, $Lab1Pos2, 70)
89$Lab1Pos2 = $Lab1Pos2 + 20
90$label2 = GUICtrlCreateLabel("", $Lab1Pos1, $Lab1Pos2, 70)
91$Lab1Pos2 = $Lab1Pos2 + 20
92$label3 = GUICtrlCreateLabel("", $Lab1Pos1, $Lab1Pos2, 70)
93$Lab1Pos2 = $Lab1Pos2 + 20
94$label4 = GUICtrlCreateLabel("", $Lab1Pos1, $Lab1Pos2, 70)
95$Lab1Pos2 = $Lab1Pos2 + 20
96$label5 = GUICtrlCreateLabel("", $Lab1Pos1, $Lab1Pos2, 70)
97$Lab1Pos2 = $Lab1Pos2 + 20
98$label6 = GUICtrlCreateLabel("", $Lab1Pos1, $Lab1Pos2, 70)
99$Lab1Pos2 = $Lab1Pos2 + 20
100$label7 = GUICtrlCreateLabel("", $Lab1Pos1, $Lab1Pos2, 70)
101$Lab1Pos1 = $Lab1Pos1 - 38
102$Lab1Pos2 = $Lab1Pos2 + 32
103$ButtonRefresh = GUICtrlCreateButton(" Refresh ", $Lab1Pos1, $Lab1Pos2, 80)
104$Lab1Pos1 = $Lab1Pos1 + 38
105$Lab1Pos2 = $Lab1Pos2 - 32
106
107$Adapters = _Get_Adapters()
108$Adapter = GUICtrlCreateCombo("", 100, 12, 200)
109GUICtrlSetData($Adapter,$Adapters , IniRead($SettingsFile, "Last Used Adapter", "Name", $Adapter3))
110if GUICtrlRead($Adapter) <> "" Then _Refresh_Config()
111$GetAdp = GUICtrlCreateButton(" Get Adapters ", 310, 10, 80)
112
113$hidewin = GUICtrlCreateButton("Tray", 665, 5, 30, 17)
114
115$trayabout = TrayCreateItem("About")
116$trayshowhidewin = TrayCreateItem("Hide")
117$hide = 0
118TrayCreateItem("")
119$TraySubMenu = TrayCreateMenu("Enable Config")
120$TrayEnableCon1 = TrayCreateItem(IniRead($SettingsFile, "IPConfig1", "Name", $DefautTab1Name), $TraySubMenu)
121$TrayEnableCon2 = TrayCreateItem(IniRead($SettingsFile, "IPConfig2", "Name", $DefautTab2Name), $TraySubMenu)
122$TrayEnableCon3 = TrayCreateItem(IniRead($SettingsFile, "IPConfig3", "Name", $DefautTab3Name), $TraySubMenu)
123$TrayEnableCon4 = TrayCreateItem(IniRead($SettingsFile, "IPConfig4", "Name", $DefautTab4Name), $TraySubMenu)
124TrayCreateItem("")
125$trayexit = TrayCreateItem("Exit")
126
127GUICtrlCreateTab(415, 15, 240, 260)
128$Con1Pos1 = 425 ; lefthand row
129$Con1Pos2 = 40 ; top row
130$Con2Pos1 = $Con1Pos1
131$Con3Pos2 = $Con1Pos2
132$Con2Pos2 = $Con1Pos2
133$Con3Pos1 = $Con1Pos1
134$Con4Pos1 = $Con2Pos1
135$Con4Pos2 = $Con3Pos2
136$tab1 = GUICtrlCreateTabItem(IniRead($SettingsFile, "IPConfig1", "Name", $DefautTab1Name))
137GUICtrlCreateGroup ("", $Con1Pos1, $Con1Pos2, 220, 220)
138$Con1Pos1 = $Con1Pos1 + 18
139$Con1Pos2 = $Con1Pos2 + 23
140GUICtrlCreateLabel("Name: ", $Con1Pos1, $Con1Pos2)
141$Con1Pos2 = $Con1Pos2 + 30
142GUICtrlCreateLabel("IP Address: ", $Con1Pos1, $Con1Pos2)
143$Con1Pos2 = $Con1Pos2 + 25
144GUICtrlCreateLabel("Subnet Mask: ", $Con1Pos1, $Con1Pos2)
145$Con1Pos2 = $Con1Pos2 + 25
146GUICtrlCreateLabel("Default GW: ", $Con1Pos1, $Con1Pos2)
147$Con1Pos2 = $Con1Pos2 + 25
148GUICtrlCreateLabel("DNS Server: ", $Con1Pos1, $Con1Pos2)
149$Con1Pos2 = $Con1Pos2 + 25
150GUICtrlCreateLabel("WINS Server: ", $Con1Pos1, $Con1Pos2)
151$Con1Pos1 = $Con1Pos1 + 40
152$Con1Pos2 = $Con1Pos2 - 135
153$Config1Name = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig1", "Name", $DefautTab1Name), $Con1Pos1, $Con1Pos2, 90)
154$Con1Pos1 = $Con1Pos1 + 30
155$Con1Pos2 = $Con1Pos2 + 30
156$IPaddressSet1 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig1", "IPAddress", "0.0.0.0"), $Con1Pos1, $Con1Pos2, 90)
157$Con1Pos2 = $Con1Pos2 + 25
158$SubnetSet1 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig1","SubnetMask","0.0.0.0"), $Con1Pos1, $Con1Pos2, 90)
159$Con1Pos2 = $Con1Pos2 + 25
160$DefaultGWSet1 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig1","DefaultGW","0.0.0.0"), $Con1Pos1, $Con1Pos2, 90)
161$Con1Pos2 = $Con1Pos2 + 25
162$DNSSet1 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig1","DNS","0.0.0.0"), $Con1Pos1, $Con1Pos2, 90)
163$Con1Pos2 = $Con1Pos2 + 25
164$WINSSet1 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig1","WINS","0.0.0.0"), $Con1Pos1, $Con1Pos2, 90)
165$Con1Pos1 = $Con1Pos1 - 45
166$Con1Pos2 = $Con1Pos2 + 25
167$DHCPCheck1 = GUICtrlCreateCheckbox("DHCP ", $Con1Pos1, $Con1Pos2)
168If IniRead($SettingsFile, "IPConfig1", "Use DHCP", "0") = "1" Then GUICtrlSetState($DHCPCheck1, $GUI_CHECKED)
169$Con1Pos1 = $Con1Pos1 + 60
170$Con1Pos2 = $Con1Pos2 + 5
171$SetConfig1 = GUICtrlCreateButton(" Set ", $Con1Pos1, $Con1Pos2, 35, 20)
172$Con1Pos1 = $Con1Pos1 + 50
173$ButtonSave1 = GUICtrlCreateButton(" Save ", $Con1Pos1, $Con1Pos2, 40, 20)
174
175
176$tab2 = GUICtrlCreateTabItem(IniRead($SettingsFile, "IPConfig2", "Name", $DefautTab2Name))
177GUICtrlCreateGroup ("", $Con2Pos1, $Con2Pos2, 220, 220)
178$Con2Pos1 = $Con2Pos1 + 18
179$Con2Pos2 = $Con2Pos2 + 23
180GUICtrlCreateLabel("Name: ", $Con2Pos1, $Con2Pos2)
181$Con2Pos2 = $Con2Pos2 + 30
182GUICtrlCreateLabel("IP Address: ", $Con2Pos1, $Con2Pos2)
183$Con2Pos2 = $Con2Pos2 + 25
184GUICtrlCreateLabel("Subnet Mask: ", $Con2Pos1, $Con2Pos2)
185$Con2Pos2 = $Con2Pos2 + 25
186GUICtrlCreateLabel("Default GW: ", $Con2Pos1, $Con2Pos2)
187$Con2Pos2 = $Con2Pos2 + 25
188GUICtrlCreateLabel("DNS Server: ", $Con2Pos1, $Con2Pos2)
189$Con2Pos2 = $Con2Pos2 + 25
190GUICtrlCreateLabel("WINS Server: ", $Con2Pos1, $Con2Pos2)
191$Con2Pos1 = $Con2Pos1 + 40
192$Con2Pos2 = $Con2Pos2 - 135
193$Config2Name = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig2", "Name", $DefautTab2Name), $Con2Pos1, $Con2Pos2, 90)
194$Con2Pos1 = $Con2Pos1 + 30
195$Con2Pos2 = $Con2Pos2 + 30
196$IPaddressSet2 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig2","IPAddress","0.0.0.0"), $Con2Pos1, $Con2Pos2, 90)
197$Con2Pos2 = $Con2Pos2 + 25
198$SubnetSet2 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig2","SubnetMask","0.0.0.0"), $Con2Pos1, $Con2Pos2, 90)
199$Con2Pos2 = $Con2Pos2 + 25
200$DefaultGWSet2 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig2","DefaultGW","0.0.0.0"), $Con2Pos1, $Con2Pos2, 90)
201$Con2Pos2 = $Con2Pos2 + 25
202$DNSSet2 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig2","DNS","0.0.0.0"), $Con2Pos1, $Con2Pos2, 90)
203$Con2Pos2 = $Con2Pos2 + 25
204$WINSSet2 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig2","WINS","0.0.0.0"), $Con2Pos1, $Con2Pos2, 90)
205$Con2Pos1 = $Con2Pos1 - 45
206$Con2Pos2 = $Con2Pos2 + 25
207$DHCPCheck2 = GUICtrlCreateCheckbox("DHCP ", $Con2Pos1, $Con2Pos2)
208If IniRead($SettingsFile, "IPConfig2", "Use DHCP", "0") = "1" Then GUICtrlSetState($DHCPCheck2, $GUI_CHECKED)
209$Con2Pos1 = $Con2Pos1 + 60
210$Con2Pos2 = $Con2Pos2 + 5
211$SetConfig2 = GUICtrlCreateButton(" Set ", $Con2Pos1, $Con2Pos2, 35, 20)
212$Con2Pos1 = $Con2Pos1 + 50
213$ButtonSave2 = GUICtrlCreateButton(" Save ", $Con2Pos1, $Con2Pos2, 40, 20)
214
215$tab3 = GUICtrlCreateTabItem(IniRead($SettingsFile, "IPConfig3", "Name", $DefautTab3Name))
216GUICtrlCreateGroup ("", $Con3Pos1, $Con3Pos2, 220, 220)
217$Con3Pos1 = $Con3Pos1 + 18
218$Con3Pos2 = $Con3Pos2 + 23
219GUICtrlCreateLabel("Name: ", $Con3Pos1, $Con3Pos2)
220$Con3Pos2 = $Con3Pos2 + 30
221GUICtrlCreateLabel("IP Address: ", $Con3Pos1, $Con3Pos2)
222$Con3Pos2 = $Con3Pos2 + 25
223GUICtrlCreateLabel("Subnet Mask: ", $Con3Pos1, $Con3Pos2)
224$Con3Pos2 = $Con3Pos2 + 25
225GUICtrlCreateLabel("Default GW: ", $Con3Pos1, $Con3Pos2)
226$Con3Pos2 = $Con3Pos2 + 25
227GUICtrlCreateLabel("DNS Server: ", $Con3Pos1, $Con3Pos2)
228$Con3Pos2 = $Con3Pos2 + 25
229GUICtrlCreateLabel("WINS Server: ", $Con3Pos1, $Con3Pos2)
230$Con3Pos1 = $Con3Pos1 + 40
231$Con3Pos2 = $Con3Pos2 - 135
232$Config3Name = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig3", "Name", $DefautTab3Name), $Con3Pos1, $Con3Pos2, 90)
233$Con3Pos1 = $Con3Pos1 + 30
234$Con3Pos2 = $Con3Pos2 + 30
235$IPaddressSet3 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig3","IPAddress","0.0.0.0"), $Con3Pos1, $Con3Pos2, 90)
236$Con3Pos2 = $Con3Pos2 + 25
237$SubnetSet3 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig3","SubnetMask","0.0.0.0"), $Con3Pos1, $Con3Pos2, 90)
238$Con3Pos2 = $Con3Pos2 + 25
239$DefaultGWSet3 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig3","DefaultGW","0.0.0.0"), $Con3Pos1, $Con3Pos2, 90)
240$Con3Pos2 = $Con3Pos2 + 25
241$DNSSet3 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig3","DNS","0.0.0.0"), $Con3Pos1, $Con3Pos2, 90)
242$Con3Pos2 = $Con3Pos2 + 25
243$WINSSet3 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig3","WINS","0.0.0.0"), $Con3Pos1, $Con3Pos2, 90)
244$Con3Pos1 = $Con3Pos1 - 45
245$Con3Pos2 = $Con3Pos2 + 25
246$DHCPCheck3 = GUICtrlCreateCheckbox("DHCP ", $Con3Pos1, $Con3Pos2)
247If IniRead($SettingsFile, "IPConfig3", "Use DHCP", "0") = "1" Then GUICtrlSetState($DHCPCheck3, $GUI_CHECKED)
248$Con3Pos1 = $Con3Pos1 + 60
249$Con3Pos2 = $Con3Pos2 + 5
250$SetConfig3 = GUICtrlCreateButton(" Set ", $Con3Pos1, $Con3Pos2, 35, 20)
251$Con3Pos1 = $Con3Pos1 + 50
252$ButtonSave3 = GUICtrlCreateButton(" Save ", $Con3Pos1, $Con3Pos2, 40, 20)
253
254$tab4 = GUICtrlCreateTabItem(IniRead($SettingsFile, "IPConfig4", "Name", $DefautTab4Name))
255GUICtrlCreateGroup ("", $Con4Pos1, $Con4Pos2, 220, 220)
256$Con4Pos1 = $Con4Pos1 + 18
257$Con4Pos2 = $Con4Pos2 + 23
258GUICtrlCreateLabel("Name: ", $Con4Pos1, $Con4Pos2)
259$Con4Pos2 = $Con4Pos2 + 30
260GUICtrlCreateLabel("IP Address:", $Con4Pos1, $Con4Pos2)
261$Con4Pos2 = $Con4Pos2 + 25
262GUICtrlCreateLabel("Subnet Mask:", $Con4Pos1, $Con4Pos2)
263$Con4Pos2 = $Con4Pos2 + 25
264GUICtrlCreateLabel("Default GW:", $Con4Pos1, $Con4Pos2)
265$Con4Pos2 = $Con4Pos2 + 25
266GUICtrlCreateLabel("DNS Server: ", $Con4Pos1, $Con4Pos2)
267$Con4Pos2 = $Con4Pos2 + 25
268GUICtrlCreateLabel("WINS Server: ", $Con4Pos1, $Con4Pos2)
269$Con4Pos1 = $Con4Pos1 + 40
270$Con4Pos2 = $Con4Pos2 - 135
271$Config4Name = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig4", "Name", $DefautTab4Name), $Con4Pos1, $Con4Pos2, 90)
272$Con4Pos1 = $Con4Pos1 + 30
273$Con4Pos2 = $Con4Pos2 + 30
274$IPaddressSet4 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig4","IPAddress","0.0.0.0"), $Con4Pos1, $Con4Pos2, 90)
275$Con4Pos2 = $Con4Pos2 + 25
276$SubnetSet4 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig4","SubnetMask","0.0.0.0"), $Con4Pos1, $Con4Pos2, 90)
277$Con4Pos2 = $Con4Pos2 + 25
278$DefaultGWSet4 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig4","DefaultGW","0.0.0.0"), $Con4Pos1, $Con4Pos2, 90)
279$Con4Pos2 = $Con4Pos2 + 25
280$DNSSet4 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig4","DNS","0.0.0.0"), $Con4Pos1, $Con4Pos2, 90)
281$Con4Pos2 = $Con4Pos2 + 25
282$WINSSet4 = GUICtrlCreateInput(IniRead($SettingsFile, "IPConfig4","WINS","0.0.0.0"), $Con4Pos1, $Con4Pos2, 90)
283$Con4Pos1 = $Con4Pos1 - 45
284$Con4Pos2 = $Con4Pos2 + 25
285$DHCPCheck4 = GUICtrlCreateCheckbox("DHCP ", $Con4Pos1, $Con4Pos2)
286If IniRead($SettingsFile, "IPConfig4", "Use DHCP", "0") = "1" Then GUICtrlSetState($DHCPCheck4, $GUI_CHECKED)
287$Con4Pos1 = $Con4Pos1 + 60
288$Con4Pos2 = $Con4Pos2 + 5
289$SetConfig4 = GUICtrlCreateButton(" Set ", $Con4Pos1, $Con4Pos2, 35, 20)
290$Con4Pos1 = $Con4Pos1 + 50
291$ButtonSave4 = GUICtrlCreateButton(" Save ", $Con4Pos1, $Con4Pos2, 40, 20)
292
293If $CmdLine[0] = 0 Then
294        GUISetState()
295Else
296        If $CmdLine[1] = "-p" Then
297                If Not $CmdLine[2] = "" Then
298                        $adapter3 = IniRead($SettingsFile, "Last Used Adapter", "Name", $Adapter3) ;
299                        Select
300                                Case $CmdLine[2] = 1
301                                        _Apply_Button("Button1")
302                                Case $CmdLine[2] = 2
303                                        _Apply_Button("Button2")
304                                Case $CmdLine[2] = 3
305                                        _Apply_Button("Button3")
306                                Case $CmdLine[2] = 4
307                                        _Apply_Button("Button4")
308                                Case $CmdLine[2] = 5
309                                        _Apply_Button("Button5")
310                                Case Else
311                                        CLIERROR()
312                        EndSelect
313                Else
314                        CLIERROR()
315                EndIf
316        Else
317                CLIERROR()
318        EndIf
319        Exit
320EndIf
321
322Func CLIERROR()
323        MsgBox(0, "", "Command Line Options:" & @CRLF & @CRLF & "ipchanger.exe -p <preset config(1-4)>" & @CRLF & "(Note uses the last used adapter as specified in the ini)")
324        Exit
325EndFunc
326
327while 1
328        _CheckInput($WinTitle, $Config1Name)
329        _CheckInput($WinTitle, $Config2Name)
330        _CheckInput($WinTitle, $Config3Name)
331        _CheckInput($WinTitle, $Config4Name)
332        _CheckInput($WinTitle, $Config5Name)
333       
334        $msg = GUIGetMsg()
335        $traymsg = TrayGetMsg()
336        Select
337                Case $msg = $ButtonSave1 Or $msg = $ButtonSave2 Or $msg = $ButtonSave3 Or $msg = $ButtonSave4
338                        _Set_Gui("Disable")
339                        If MsgBox(4, $WinTitle, "This will overwrite the settings file. Continue?") = 6 Then _SaveIniFile()
340                        _Set_Gui("Enable")
341                       
342                Case $msg = $SetConfig1
343                        _Set_Gui("Disable")
344                        If GUICtrlRead($Adapter) = "" Then
345                                MsgBox(0, $WinTitle, $NoteString5)
346                                GUICtrlSetData($statuslabel, $NoteString5)
347                        Else
348                                _Apply_Button("Button1")
349                        EndIf
350                        _Set_Gui("Enable")
351                       
352                Case $msg = $SetConfig2
353                        _Set_Gui("Disable")
354                        If GUICtrlRead($Adapter) = "" Then
355                                MsgBox(0, $WinTitle, $NoteString5)
356                                GUICtrlSetData($statuslabel, $NoteString5)
357                        Else
358                                _Apply_Button("Button2")
359                        EndIf
360                        _Set_Gui("Enable")
361                       
362                Case $msg = $SetConfig3
363                        _Set_Gui("Disable")
364                        If GUICtrlRead($Adapter) = "" Then
365                                MsgBox(0, $WinTitle, $NoteString5)
366                                GUICtrlSetData($statuslabel, $NoteString5)
367                        Else
368                                _Apply_Button("Button3")
369                        EndIf
370                        _Set_Gui("Enable")
371                       
372                Case $msg = $SetConfig4
373                        _Set_Gui("Disable")
374                        If GUICtrlRead($Adapter) = "" Then
375                                MsgBox(0, $WinTitle, $NoteString5)
376                                GUICtrlSetData($statuslabel, $NoteString5)
377                        Else
378                                _Apply_Button("Button4")
379                        EndIf
380                        _Set_Gui("Enable")
381
382                Case $msg = $SetConfig5
383                        _Set_Gui("Disable")
384                        If GUICtrlRead($Adapter) = "" Then
385                                MsgBox(0, $WinTitle, $NoteString5)
386                                GUICtrlSetData($statuslabel, $NoteString5)
387                        Else
388                                _Apply_Button("Button5")
389                        EndIf
390                        _Set_Gui("Enable")
391                       
392                Case $msg = $GUI_EVENT_CLOSE
393                        _Set_Gui("Disable")
394                        _Exit()
395                       
396                Case $msg = $ButtonRefresh
397                        _Set_Gui("Disable")
398                        If GUICtrlRead($Adapter) = "" Then
399                                MsgBox(0, $WinTitle, $NoteString5)
400                                GUICtrlSetData($statuslabel, $NoteString5)
401                        Else
402                                _Refresh_Config()
403                        EndIf
404                        _Set_Gui("Enable")
405                       
406                Case $msg = $Adapter
407                        _Set_Gui("Disable")
408                        _Refresh_Config()
409                        _Set_Gui("Enable")
410                       
411                Case $msg = $GetAdp
412                        _Set_Gui("Disable")
413                        GUICtrlSetData($Adapter, _Get_Adapters(), GUICtrlRead($Adapter))
414                        _Refresh_Config()
415                        _Set_Gui("Enable")
416                       
417                Case $msg = $hidewin
418                        show_hide_win()
419                       
420                Case $traymsg = $trayexit
421                        _Exit()
422                       
423                Case $traymsg = $trayabout
424                        MsgBox(0,$WinTitle,$WelcomeMSG & $WelcomeWarning)
425                       
426                Case $traymsg = $trayshowhidewin
427                        show_hide_win()
428                       
429                Case $traymsg = $TrayEnableCon1
430                        $adapter3 = IniRead($SettingsFile, "Last Used Adapter", "Name", $Adapter3)
431                        _Apply_Button("Button1")
432                       
433                Case $traymsg = $TrayEnableCon2
434                        $adapter3 = IniRead($SettingsFile, "Last Used Adapter", "Name", $Adapter3)
435                        _Apply_Button("Button2")
436                       
437                Case $traymsg = $TrayEnableCon3
438                        $adapter3 = IniRead($SettingsFile, "Last Used Adapter", "Name", $Adapter3)
439                        _Apply_Button("Button3")
440                       
441                Case $traymsg = $TrayEnableCon4
442                        $adapter3 = IniRead($SettingsFile, "Last Used Adapter", "Name", $Adapter3)
443                        _Apply_Button("Button4")
444
445                Case $traymsg = $TrayEnableCon5
446                        $adapter3 = IniRead($SettingsFile, "Last Used Adapter", "Name", $Adapter3)
447                        _Apply_Button("Button5")
448                       
449        EndSelect
450        If GUICtrlRead($DHCPCheck1) = $GUI_CHECKED and $check1 = 0 Then
451                GUICtrlSetState($IPaddressSet1, $GUI_DISABLE)
452                GUICtrlSetState($SubnetSet1, $GUI_DISABLE)
453                GUICtrlSetState($DefaultGWSet1, $GUI_DISABLE)
454                GUICtrlSetState($DNSSet1, $GUI_DISABLE)
455                GUICtrlSetState($WINSSet1, $GUI_DISABLE)
456                $check1 = 1
457        EndIf
458        If GUICtrlRead($DHCPCheck1) = $GUI_UNCHECKED and $check1 = 1 Then
459                GUICtrlSetState($IPaddressSet1, $GUI_ENABLE)
460                GUICtrlSetState($SubnetSet1, $GUI_ENABLE)
461                GUICtrlSetState($DefaultGWSet1, $GUI_ENABLE)
462                GUICtrlSetState($DNSSet1, $GUI_ENABLE)
463                GUICtrlSetState($WINSSet1, $GUI_ENABLE)
464                $check1 = 0
465        EndIf
466       
467        If GUICtrlRead($DHCPCheck2) = $GUI_CHECKED and $check2 = 0 Then
468                GUICtrlSetState($IPaddressSet2, $GUI_DISABLE)
469                GUICtrlSetState($SubnetSet2, $GUI_DISABLE)
470                GUICtrlSetState($DefaultGWSet2, $GUI_DISABLE)
471                GUICtrlSetState($DNSSet2, $GUI_DISABLE)
472                GUICtrlSetState($WINSSet2, $GUI_DISABLE)
473                $check2 = 1
474        EndIf
475        If GUICtrlRead($DHCPCheck2) = $GUI_UNCHECKED and $check2 = 1 Then
476                GUICtrlSetState($IPaddressSet2, $GUI_ENABLE)
477                GUICtrlSetState($SubnetSet2, $GUI_ENABLE)
478                GUICtrlSetState($DefaultGWSet2, $GUI_ENABLE)
479                GUICtrlSetState($DNSSet2, $GUI_ENABLE)
480                GUICtrlSetState($WINSSet2, $GUI_ENABLE)
481                $check2 = 0
482        EndIf
483       
484        If GUICtrlRead($DHCPCheck3) = $GUI_CHECKED and $check3 = 0 Then
485                GUICtrlSetState($IPaddressSet3, $GUI_DISABLE)
486                GUICtrlSetState($SubnetSet3, $GUI_DISABLE)
487                GUICtrlSetState($DefaultGWSet3, $GUI_DISABLE)
488                GUICtrlSetState($DNSSet3, $GUI_DISABLE)
489                GUICtrlSetState($WINSSet3, $GUI_DISABLE)
490                $check3 = 1
491        EndIf
492        If GUICtrlRead($DHCPCheck3) = $GUI_UNCHECKED and $check3 = 1 Then
493                GUICtrlSetState($IPaddressSet3, $GUI_ENABLE)
494                GUICtrlSetState($SubnetSet3, $GUI_ENABLE)
495                GUICtrlSetState($DefaultGWSet3, $GUI_ENABLE)
496                GUICtrlSetState($DNSSet3, $GUI_ENABLE)
497                GUICtrlSetState($WINSSet3, $GUI_ENABLE)
498                $check3 = 0
499        EndIf
500       
501        If GUICtrlRead($DHCPCheck4) = $GUI_CHECKED and $check4 = 0 Then
502                GUICtrlSetState($IPaddressSet4, $GUI_DISABLE)
503                GUICtrlSetState($SubnetSet4, $GUI_DISABLE)
504                GUICtrlSetState($DefaultGWSet4, $GUI_DISABLE)
505                GUICtrlSetState($DNSSet4, $GUI_DISABLE)
506                GUICtrlSetState($WINSSet4, $GUI_DISABLE)
507                $check4 = 1
508        EndIf
509        If GUICtrlRead($DHCPCheck4) = $GUI_UNCHECKED and $check4 = 1 Then
510                GUICtrlSetState($IPaddressSet4, $GUI_ENABLE)
511                GUICtrlSetState($SubnetSet4, $GUI_ENABLE)
512                GUICtrlSetState($DefaultGWSet4, $GUI_ENABLE)
513                GUICtrlSetState($DNSSet4, $GUI_ENABLE)
514                GUICtrlSetState($WINSSet4, $GUI_ENABLE)
515                $check4 = 0
516        EndIf
517
518        If GUICtrlRead($DHCPCheck5) = $GUI_CHECKED and $check5 = 0 Then
519                GUICtrlSetState($IPaddressSet5, $GUI_DISABLE)
520                GUICtrlSetState($SubnetSet5, $GUI_DISABLE)
521                GUICtrlSetState($DefaultGWSet4, $GUI_DISABLE)
522                GUICtrlSetState($DNSSet5, $GUI_DISABLE)
523                GUICtrlSetState($WINSSet5, $GUI_DISABLE)
524                $check5 = 1
525        EndIf
526        If GUICtrlRead($DHCPCheck5) = $GUI_UNCHECKED and $check5 = 1 Then
527                GUICtrlSetState($IPaddressSet5, $GUI_ENABLE)
528                GUICtrlSetState($SubnetSet5, $GUI_ENABLE)
529                GUICtrlSetState($DefaultGWSet5, $GUI_ENABLE)
530                GUICtrlSetState($DNSSet5, $GUI_ENABLE)
531                GUICtrlSetState($WINSSet5, $GUI_ENABLE)
532                $check5 = 0
533        EndIf
534WEnd
535
536Func ChangeConfigName()
537        GUICtrlSetData($tab1, GUICtrlRead($Config1Name))
538        GUICtrlSetData($tab2, GUICtrlRead($Config2Name))
539        GUICtrlSetData($tab3, GUICtrlRead($Config3Name))
540        GUICtrlSetData($tab4, GUICtrlRead($Config4Name))
541        GUICtrlSetData($tab5, GUICtrlRead($Config5Name))
542        TrayItemDelete($TrayEnableCon1)
543        TrayItemDelete($TrayEnableCon2)
544        TrayItemDelete($TrayEnableCon3)
545        TrayItemDelete($TrayEnableCon4)
546        TrayItemDelete($TrayEnableCon5)
547        $TrayEnableCon1 = TrayCreateItem(GUICtrlRead($Config1Name), $TraySubMenu)
548        $TrayEnableCon2 = TrayCreateItem(GUICtrlRead($Config2Name), $TraySubMenu)
549        $TrayEnableCon3 = TrayCreateItem(GUICtrlRead($Config3Name), $TraySubMenu)
550        $TrayEnableCon4 = TrayCreateItem(GUICtrlRead($Config4Name), $TraySubMenu)
551        $TrayEnableCon5 = TrayCreateItem(GUICtrlRead($Config5Name), $TraySubMenu)
552
553EndFunc
554
555Func show_hide_win()
556        If $hide = 0 Then
557                TrayItemSetText($trayshowhidewin, "Show")
558                $hide = 1
559                GUISetState(@SW_MINIMIZE, $WinTitle)
560                GUISetState(@SW_HIDE, $WinTitle)
561        ElseIf $hide = 1 Then
562                TrayItemSetText($trayshowhidewin, "Hide")
563                $hide = 0
564                GUISetState(@SW_SHOW, $WinTitle)
565                GUISetState(@SW_RESTORE, $WinTitle)
566        Else
567                Return
568        EndIf
569EndFunc
570
571Func _CheckInput($hWnd, $ID)
572    If $Mark = 0 And _IsFocused($hWnd, $ID) Then
573        $Mark = 1
574
575    ElseIf $Mark = 1 And Not _IsFocused($hWnd, $ID) Then
576        $Mark = 0
577                ChangeConfigName()
578    EndIf
579       
580EndFunc
581
582Func _IsFocused($hWnd, $nCID)
583    Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
584EndFunc
585
586Func _Set_Gui($a)
587        If $a = "Enable" Then
588                GUICtrlSetState($DHCPCheck1, $GUI_ENABLE)
589                GUICtrlSetState($DHCPCheck2, $GUI_ENABLE)
590                GUICtrlSetState($DHCPCheck3, $GUI_ENABLE)
591                GUICtrlSetState($DHCPCheck4, $GUI_ENABLE)
592                GUICtrlSetState($DHCPCheck5, $GUI_ENABLE)
593                If GUICtrlRead($DHCPCheck1) = $GUI_CHECKED Then
594                        GUICtrlSetState($IPaddressSet1, $GUI_DISABLE)
595                        GUICtrlSetState($SubnetSet1, $GUI_DISABLE)
596                        GUICtrlSetState($DefaultGWSet1, $GUI_DISABLE)
597                        GUICtrlSetState($DNSSet1, $GUI_DISABLE)
598                        GUICtrlSetState($WINSSet1, $GUI_DISABLE)
599                        $check1 = 0
600                Else
601                        GUICtrlSetState($IPaddressSet1, $GUI_ENABLE)
602                        GUICtrlSetState($SubnetSet1, $GUI_ENABLE)
603                        GUICtrlSetState($DefaultGWSet1, $GUI_ENABLE)
604                        GUICtrlSetState($DNSSet1, $GUI_ENABLE)
605                        GUICtrlSetState($WINSSet1, $GUI_ENABLE)
606                EndIf
607               
608                If GUICtrlRead($DHCPCheck2) = $GUI_CHECKED Then
609                        GUICtrlSetState($IPaddressSet2, $GUI_DISABLE)
610                        GUICtrlSetState($SubnetSet2, $GUI_DISABLE)
611                        GUICtrlSetState($DefaultGWSet2, $GUI_DISABLE)
612                        GUICtrlSetState($DNSSet2, $GUI_DISABLE)
613                        GUICtrlSetState($WINSSet2, $GUI_DISABLE)
614                        $check2 = 0
615                Else
616                        GUICtrlSetState($IPaddressSet2, $GUI_ENABLE)
617                        GUICtrlSetState($SubnetSet2, $GUI_ENABLE)
618                        GUICtrlSetState($DefaultGWSet2, $GUI_ENABLE)
619                        GUICtrlSetState($DNSSet2, $GUI_ENABLE)
620                        GUICtrlSetState($WINSSet2, $GUI_ENABLE)
621                EndIf
622               
623                If GUICtrlRead($DHCPCheck3) = $GUI_CHECKED Then
624                        GUICtrlSetState($IPaddressSet3, $GUI_DISABLE)
625                        GUICtrlSetState($SubnetSet3, $GUI_DISABLE)
626                        GUICtrlSetState($DefaultGWSet3, $GUI_DISABLE)
627                        GUICtrlSetState($DNSSet3, $GUI_DISABLE)
628                        GUICtrlSetState($WINSSet3, $GUI_DISABLE)
629                        $check3 = 0
630                Else
631                        GUICtrlSetState($IPaddressSet3, $GUI_ENABLE)
632                        GUICtrlSetState($SubnetSet3, $GUI_ENABLE)
633                        GUICtrlSetState($DefaultGWSet3, $GUI_ENABLE)
634                        GUICtrlSetState($DNSSet3, $GUI_ENABLE)
635                        GUICtrlSetState($WINSSet3, $GUI_ENABLE)
636                EndIf
637               
638                If GUICtrlRead($DHCPCheck4) = $GUI_CHECKED Then
639                        GUICtrlSetState($IPaddressSet4, $GUI_DISABLE)
640                        GUICtrlSetState($SubnetSet4, $GUI_DISABLE)
641                        GUICtrlSetState($DefaultGWSet4, $GUI_DISABLE)
642                        GUICtrlSetState($DNSSet4, $GUI_DISABLE)
643                        GUICtrlSetState($WINSSet4, $GUI_DISABLE)
644                        $check4 = 0
645                Else
646                        GUICtrlSetState($IPaddressSet4, $GUI_ENABLE)
647                        GUICtrlSetState($SubnetSet4, $GUI_ENABLE)
648                        GUICtrlSetState($DefaultGWSet4, $GUI_ENABLE)
649                        GUICtrlSetState($DHCPCheck4, $GUI_ENABLE)
650                        GUICtrlSetState($DNSSet4, $GUI_ENABLE)
651                        GUICtrlSetState($WINSSet4, $GUI_ENABLE)
652                EndIf
653
654                If GUICtrlRead($DHCPCheck5) = $GUI_CHECKED Then
655                        GUICtrlSetState($IPaddressSet5, $GUI_DISABLE)
656                        GUICtrlSetState($SubnetSet5, $GUI_DISABLE)
657                        GUICtrlSetState($DefaultGWSet5, $GUI_DISABLE)
658                        GUICtrlSetState($DNSSet5, $GUI_DISABLE)
659                        GUICtrlSetState($WINSSet5, $GUI_DISABLE)
660                        $check4 = 0
661                Else
662                        GUICtrlSetState($IPaddressSet5, $GUI_ENABLE)
663                        GUICtrlSetState($SubnetSet5, $GUI_ENABLE)
664                        GUICtrlSetState($DefaultGWSet5, $GUI_ENABLE)
665                        GUICtrlSetState($DHCPCheck5, $GUI_ENABLE)
666                        GUICtrlSetState($DNSSet5, $GUI_ENABLE)
667                        GUICtrlSetState($WINSSet5, $GUI_ENABLE)
668                EndIf
669                GUICtrlSetState($Config1Name, $GUI_ENABLE)
670                GUICtrlSetState($ButtonSave1, $GUI_ENABLE)
671                GUICtrlSetState($SetConfig1, $GUI_ENABLE)
672                GUICtrlSetState($Config2Name, $GUI_ENABLE)
673                GUICtrlSetState($ButtonSave2, $GUI_ENABLE)
674                GUICtrlSetState($SetConfig2, $GUI_ENABLE)
675                GUICtrlSetState($Config3Name, $GUI_ENABLE)
676                GUICtrlSetState($ButtonSave3, $GUI_ENABLE)
677                GUICtrlSetState($SetConfig3, $GUI_ENABLE)
678                GUICtrlSetState($Config4Name, $GUI_ENABLE)
679                GUICtrlSetState($ButtonSave4, $GUI_ENABLE)
680                GUICtrlSetState($SetConfig4, $GUI_ENABLE)
681                GUICtrlSetState($Config5Name, $GUI_ENABLE)
682                GUICtrlSetState($ButtonSave5, $GUI_ENABLE)
683                GUICtrlSetState($SetConfig5, $GUI_ENABLE)
684                GUICtrlSetState($Adapter, $GUI_ENABLE)
685                GUICtrlSetState($GetAdp, $GUI_ENABLE)
686                GUICtrlSetState($ButtonRefresh, $GUI_ENABLE)
687               
688        ElseIf $a = "Disable" Then
689                GUICtrlSetState($Config1Name, $GUI_DISABLE)
690                GUICtrlSetState($IPaddressSet1, $GUI_DISABLE)
691                GUICtrlSetState($SubnetSet1, $GUI_DISABLE)
692                GUICtrlSetState($DefaultGWSet1, $GUI_DISABLE)
693                GUICtrlSetState($DHCPCheck1, $GUI_DISABLE)
694                GUICtrlSetState($DNSSet1, $GUI_DISABLE)
695                GUICtrlSetState($WINSSet1, $GUI_DISABLE)
696                GUICtrlSetState($ButtonSave1, $GUI_DISABLE)
697                GUICtrlSetState($SetConfig1, $GUI_DISABLE)
698                GUICtrlSetState($Config2Name, $GUI_DISABLE)
699                GUICtrlSetState($IPaddressSet2, $GUI_DISABLE)
700                GUICtrlSetState($SubnetSet2, $GUI_DISABLE)
701                GUICtrlSetState($DefaultGWSet2, $GUI_DISABLE)
702                GUICtrlSetState($DHCPCheck2, $GUI_DISABLE)
703                GUICtrlSetState($DNSSet2, $GUI_DISABLE)
704                GUICtrlSetState($WINSSet2, $GUI_DISABLE)
705                GUICtrlSetState($ButtonSave2, $GUI_DISABLE)
706                GUICtrlSetState($SetConfig2, $GUI_DISABLE)
707                GUICtrlSetState($Config3Name, $GUI_DISABLE)
708                GUICtrlSetState($IPaddressSet3, $GUI_DISABLE)
709                GUICtrlSetState($SubnetSet3, $GUI_DISABLE)
710                GUICtrlSetState($DefaultGWSet3, $GUI_DISABLE)
711                GUICtrlSetState($DHCPCheck3, $GUI_DISABLE)
712                GUICtrlSetState($DNSSet3, $GUI_DISABLE)
713                GUICtrlSetState($WINSSet3, $GUI_DISABLE)
714                GUICtrlSetState($ButtonSave3, $GUI_DISABLE)
715                GUICtrlSetState($SetConfig3, $GUI_DISABLE)
716                GUICtrlSetState($Config4Name, $GUI_DISABLE)
717                GUICtrlSetState($IPaddressSet4, $GUI_DISABLE)
718                GUICtrlSetState($SubnetSet4, $GUI_DISABLE)
719                GUICtrlSetState($DefaultGWSet4, $GUI_DISABLE)
720                GUICtrlSetState($DHCPCheck4, $GUI_DISABLE)
721                GUICtrlSetState($DNSSet4, $GUI_DISABLE)
722                GUICtrlSetState($WINSSet4, $GUI_DISABLE)
723                GUICtrlSetState($ButtonSave4, $GUI_DISABLE)
724                GUICtrlSetState($SetConfig4, $GUI_DISABLE)
725                GUICtrlSetState($Config5Name, $GUI_DISABLE)
726                GUICtrlSetState($IPaddressSet5, $GUI_DISABLE)
727                GUICtrlSetState($SubnetSet5, $GUI_DISABLE)
728                GUICtrlSetState($DefaultGWSet5, $GUI_DISABLE)
729                GUICtrlSetState($DHCPCheck5, $GUI_DISABLE)
730                GUICtrlSetState($DNSSet5, $GUI_DISABLE)
731                GUICtrlSetState($WINSSet5, $GUI_DISABLE)
732                GUICtrlSetState($ButtonSave5, $GUI_DISABLE)
733                GUICtrlSetState($SetConfig5, $GUI_DISABLE)
734                GUICtrlSetState($GetAdp, $GUI_DISABLE)
735                GUICtrlSetState($ButtonRefresh, $GUI_DISABLE)
736        EndIf
737EndFunc
738
739Func _Apply_Button($a)
740        Select
741                Case $a = "Button1"
742                        If GUICtrlRead($IPaddressSet1) = "" Then GUICtrlSetData($IPaddressSet1, "0.0.0.0")
743                        If GUICtrlRead($SubnetSet1) = "" Then GUICtrlSetData($SubnetSet1, "0.0.0.0")
744                        If GUICtrlRead($DefaultGWSet1) = "" Then GUICtrlSetData($DefaultGWSet1, "0.0.0.0")
745                        If GUICtrlRead($DNSSet1) = "" Then GUICtrlSetData($DNSSet1, "0.0.0.0")
746                        If GUICtrlRead($WINSSet1) = "" Then GUICtrlSetData($WINSSet1, "0.0.0.0")
747                        If GUICtrlRead($DHCPCheck1) = $GUI_CHECKED Then
748                                _Set_DHCP(GUICtrlRead($Adapter))
749                        Else
750                                _Set_ip(GUICtrlRead($Adapter), GUICtrlRead($IPaddressSet1), GUICtrlRead($SubnetSet1), GUICtrlRead($DefaultGWSet1), GUICtrlRead($DNSSet1), GUICtrlRead($WINSSet1))
751                        EndIf
752                       
753                Case $a = "Button2"
754                        If GUICtrlRead($IPaddressSet2) = "" Then GUICtrlSetData($IPaddressSet2, "0.0.0.0")
755                        If GUICtrlRead($SubnetSet2) = "" Then GUICtrlSetData($SubnetSet2, "0.0.0.0")
756                        If GUICtrlRead($DefaultGWSet2) = "" Then GUICtrlSetData($DefaultGWSet2, "0.0.0.0")
757                        If GUICtrlRead($DNSSet2) = "" Then GUICtrlSetData($DNSSet2, "0.0.0.0")
758                        If GUICtrlRead($WINSSet2) = "" Then GUICtrlSetData($WINSSet2, "0.0.0.0")
759                        If GUICtrlRead($DHCPCheck2) = $GUI_CHECKED Then
760                                _Set_DHCP(GUICtrlRead($Adapter))
761                        Else
762                                _Set_ip(GUICtrlRead($Adapter), GUICtrlRead($IPaddressSet2), GUICtrlRead($SubnetSet2), GUICtrlRead($DefaultGWSet2), GUICtrlRead($DNSSet2), GUICtrlRead($WINSSet2))
763                        EndIf
764                       
765                Case $a = "Button3"
766                        If GUICtrlRead($IPaddressSet3) = "" Then GUICtrlSetData($IPaddressSet3, "0.0.0.0")
767                        If GUICtrlRead($SubnetSet3) = "" Then GUICtrlSetData($SubnetSet3, "0.0.0.0")
768                        If GUICtrlRead($DefaultGWSet3) = "" Then GUICtrlSetData($DefaultGWSet3, "0.0.0.0")
769                        If GUICtrlRead($DNSSet3) = "" Then GUICtrlSetData($DNSSet3, "0.0.0.0")
770                        If GUICtrlRead($WINSSet3) = "" Then GUICtrlSetData($WINSSet3, "0.0.0.0")
771                        If GUICtrlRead($DHCPCheck3) = $GUI_CHECKED Then
772                                _Set_DHCP(GUICtrlRead($Adapter))
773                        Else
774                                _Set_ip(GUICtrlRead($Adapter), GUICtrlRead($IPaddressSet3), GUICtrlRead($SubnetSet3), GUICtrlRead($DefaultGWSet3), GUICtrlRead($DNSSet3), GUICtrlRead($WINSSet3))
775                        EndIf
776                       
777                Case $a = "Button4"
778                        If GUICtrlRead($IPaddressSet4) = "" Then GUICtrlSetData($IPaddressSet4, "0.0.0.0")
779                        If GUICtrlRead($SubnetSet4) = "" Then GUICtrlSetData($SubnetSet4, "0.0.0.0")
780                        If GUICtrlRead($DefaultGWSet4) = "" Then GUICtrlSetData($DefaultGWSet4, "0.0.0.0")
781                        If GUICtrlRead($DNSSet4) = "" Then GUICtrlSetData($DNSSet4, "0.0.0.0")
782                        If GUICtrlRead($WINSSet4) = "" Then GUICtrlSetData($WINSSet4, "0.0.0.0")
783                        If GUICtrlRead($DHCPCheck4) = $GUI_CHECKED Then
784                                _Set_DHCP(GUICtrlRead($Adapter))
785                        Else
786                                _Set_ip(GUICtrlRead($Adapter), GUICtrlRead($IPaddressSet4), GUICtrlRead($SubnetSet4), GUICtrlRead($DefaultGWSet4), GUICtrlRead($DNSSet4), GUICtrlRead($WINSSet4))
787                        EndIf
788
789                Case $a = "Button5"
790                        If GUICtrlRead($IPaddressSet5) = "" Then GUICtrlSetData($IPaddressSet5, "0.0.0.0")
791                        If GUICtrlRead($SubnetSet5) = "" Then GUICtrlSetData($SubnetSet5, "0.0.0.0")
792                        If GUICtrlRead($DefaultGWSet5) = "" Then GUICtrlSetData($DefaultGWSet5, "0.0.0.0")
793                        If GUICtrlRead($DNSSet5) = "" Then GUICtrlSetData($DNSSet5, "0.0.0.0")
794                        If GUICtrlRead($WINSSet5) = "" Then GUICtrlSetData($WINSSet5, "0.0.0.0")
795                        If GUICtrlRead($DHCPCheck5) = $GUI_CHECKED Then
796                                _Set_DHCP(GUICtrlRead($Adapter))
797                        Else
798                                _Set_ip(GUICtrlRead($Adapter), GUICtrlRead($IPaddressSet5), GUICtrlRead($SubnetSet5), GUICtrlRead($DefaultGWSet5), GUICtrlRead($DNSSet5), GUICtrlRead($WINSSet5))
799                        EndIf
800                       
801        EndSelect
802EndFunc
803
804Func _Set_DHCP($name)
805        $DHCP = _Test_DHCP($Adapter)
806        ProgressOn($WinTitle, "Changing IP Address")
807        GUICtrlSetData($statuslabel, "")
808        $run = RunWait(@ComSpec & " /c " & 'netsh interface ip set address name="' & $name & '" source=dhcp', "", $show)
809        ProgressSet(25)
810        $run3 = RunWait(@ComSpec & " /c " & 'netsh int ip set dns "' & $name & '" dhcp', "", $show)
811        RunWait(@ComSpec & " /c " & 'netsh interface ip set wins "' & $name & '" dhcp', "", $show)
812        ProgressSet(50)
813        RunWait(@ComSpec & " /c " & 'ipconfig /release "' & $name & '"', "", $show)
814        ProgressSet(75)
815        $run2 = RunWait(@ComSpec & " /c " & 'ipconfig /renew "' & $name & '"', "", $show)
816        ProgressSet(100)
817        Sleep(500)
818        ProgressOff()
819        If $run = 0 Then
820                MsgBox(0, $WinTitle, $NoteString4)
821                GUICtrlSetData($statuslabel, $NoteString4)
822        ElseIf $run2 <> 0 Then
823                MsgBox(0, $WinTitle, $NoteString6)
824                GUICtrlSetData($statuslabel, $NoteString6)
825        ElseIf $run3 <> 0 Then
826                MsgBox(0, $WinTitle, $NoteString7)
827        Else
828                MsgBox(0, $WinTitle, $NoteString1)
829                GUICtrlSetData($statuslabel, $NoteString1)
830        EndIf
831        _Refresh_Config()
832EndFunc
833
834Func _Set_ip($name, $IP, $Subnet, $DefaultGW, $DNS, $WINS)
835        ProgressOn($WinTitle, "Changing IP Address")
836        GUICtrlSetData($statuslabel, "")
837        $run = RunWait(@ComSpec & " /c " & 'netsh interface ip set address name="' & $name & '" static ' & $IP & " " & $Subnet & " " & $DefaultGW & " 1", "", $show)
838        ProgressSet(50)
839        $rundns = RunWait(@ComSpec & " /c " & 'netsh interface ip set dns name="' & $name & '" static ' & $DNS, "", $show)
840        $runwins = RunWait(@ComSpec & " /c " & 'netsh interface ip set wins name="' & $name & '" static ' & $WINS, "", $show)
841        ProgressSet(100)
842        Sleep(500)
843        ProgressOff()
844        If $run = 0 Then
845                MsgBox(0,$WinTitle, $NoteString4)
846                GUICtrlSetData($statuslabel, $NoteString4)
847                Sleep(1000)
848        Else
849                MsgBox(0,$WinTitle, $NoteString1)
850                GUICtrlSetData($statuslabel, $NoteString1)
851        EndIf
852        _Refresh_Config()
853EndFunc
854
855Func _Refresh_Config()
856        SplashTextOn($WinTitle, "Please Wait...", 170, 40)
857        GUICtrlDelete($label1)
858        GUICtrlDelete($label2)
859        GUICtrlDelete($label3)
860        GUICtrlDelete($label4)
861        GUICtrlDelete($label5)
862        GUICtrlDelete($label6)
863        GUICtrlDelete($label7)
864        GUICtrlSetData($statuslabel, "")
865        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
866        for $objItem in $colItems
867                If $objItem.NetConnectionID = GUICtrlRead($Adapter) Then
868                        $Adapter2 = $objItem.caption
869                        ExitLoop
870                EndIf
871        Next
872        $IPaddress = _Refresh_IP($Adapter2)
873        $Subnet = _Refresh_Subnet($Adapter2)
874        $DefaultGW = _Refresh_DefaultGW($Adapter2)
875        $DNSServer = _Refresh_DNSServer($Adapter2)
876        $WINSServer = _Refresh_WINS($Adapter2)
877        $DHCP = _Test_DHCP($Adapter2)
878        $DHCPServer = _Refresh_DHCPServer($Adapter2)
879       
880        SplashOff()
881        $Lab1Pos2 = $Lab1Pos2 - 120
882        $label1 = GUICtrlCreateLabel($IPaddress, $Lab1Pos1, $Lab1Pos2)
883        $Lab1Pos2 = $Lab1Pos2 + 20
884        $label2 = GUICtrlCreateLabel($Subnet, $Lab1Pos1, $Lab1Pos2)
885        $Lab1Pos2 = $Lab1Pos2 + 20
886        $label3 = GUICtrlCreateLabel($DefaultGW, $Lab1Pos1, $Lab1Pos2)
887        $Lab1Pos2 = $Lab1Pos2 + 20
888        $label4 = GUICtrlCreateLabel($DNSServer, $Lab1Pos1, $Lab1Pos2)
889        $Lab1Pos2 = $Lab1Pos2 + 20
890        $label5 = GUICtrlCreateLabel($WINSServer, $Lab1Pos1, $Lab1Pos2)
891        $Lab1Pos2 = $Lab1Pos2 + 20
892        $label6 = GUICtrlCreateLabel($DHCP, $Lab1Pos1, $Lab1Pos2)
893        $Lab1Pos2 = $Lab1Pos2 + 20
894        $label7 = GUICtrlCreateLabel($DHCPServer, $Lab1Pos1, $Lab1Pos2)
895        If $IPaddress = "0.0.0.0" Then GUICtrlSetData($statuslabel, $NoteString2)
896EndFunc
897
898Func _Refresh_IP($a)
899        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
900        For $objItem In $colItems
901                If $objItem.caption = $a Then
902                        $IPaddress = $objItem.IPAddress(0)
903                        Return $IPaddress
904                EndIf
905        Next
906EndFunc
907
908Func _Refresh_Subnet($a)
909        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
910        For $objItem In $colItems
911                $Subnet = $objItem.IPSubnet(0)
912                If $objItem.caption = $a Then
913                        Return $Subnet
914                EndIf
915        Next
916EndFunc
917
918Func _Refresh_DefaultGW($a)
919        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
920        For $objItem In $colItems
921                $DefaultGW = $objItem.DefaultIPGateway(0)
922                If $objItem.caption = $a Then
923                        Return $DefaultGW
924                EndIf
925        Next
926EndFunc
927
928Func _Refresh_DNSServer($a)
929        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
930                For $objItem In $colItems
931                $DNSServer = $objItem.DNSServerSearchOrder(0)
932                If $objItem.caption = $a Then
933                        If $DNSServer = "0" Then $DNSServer = "Not Set"
934                        Return $DNSServer
935                EndIf
936        Next
937EndFunc
938
939
940Func _Refresh_WINS($a)
941        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
942                For $objItem In $colItems
943                $WINSServer = $objItem.WINSPrimaryServer
944                If $objItem.caption = $a Then
945                        If $WINSServer = "0" or $WINSServer = "" Then $WINSServer = "Not Set"
946                        Return $WINSServer
947                EndIf
948        Next
949EndFunc
950
951Func _Test_DHCP($a)
952        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
953        For $objItem In $colItems
954                $DHCPEnabled = $objItem.DHCPEnabled
955                If $objItem.caption = $a Then
956                        If $DHCPEnabled <> 0 Then
957                                $DHCPEnabled2 = "Yes"
958                        Else
959                                $DHCPEnabled2 = "No"
960                        EndIf
961                        Return $DHCPEnabled2
962                EndIf
963        Next
964EndFunc
965
966Func _Refresh_DHCPServer($a)
967        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
968                For $objItem In $colItems
969                $DHCPServer = $objItem.DHCPServer
970                If $objItem.caption = $a Then
971                        If $DHCPServer = "0" or $DHCPServer = "" Then $DHCPServer = "Not Set"
972                        Return $DHCPServer
973                EndIf
974        Next
975EndFunc
976
977Func _Get_Adapters()
978        GUICtrlSetData($statuslabel, "")
979        $Adapters = ""
980        SplashTextOn($WinTitle, "Please Wait...", 170, 40)
981        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
982        For     $objItem in $colItems
983                If $objItem.NetConnectionID <> "" Then $Adapters = $Adapters & "|" & $objItem.NetConnectionID
984        Next
985        SplashOff()
986        If $Adapters = "" Then GUICtrlSetData($statuslabel, $NoteString3)
987        Return $Adapters
988EndFunc
989
990Func _Exit()
991        $ExitMsgBox = MsgBox(3, $WinTitle, "Save Settings?")
992        If $ExitMsgBox = 6 Then
993                _SaveIniFile()
994                Exit
995        ElseIf $ExitMsgBox = 7 Then
996                Exit
997        Else
998                _Set_Gui("Enable")
999                Return
1000        EndIf
1001EndFunc
1002
1003Func _SaveIniFile()
1004        FileDelete($SettingsFile)
1005        IniWrite($SettingsFile, "Program Options", "Welcome MSG", $WelcomeEnable)
1006        If $show = @SW_SHOW Then
1007                IniWrite($SettingsFile, "Program Options", "Debug", "1")
1008        Else
1009                IniWrite($SettingsFile, "Program Options", "Debug", "0")
1010        EndIf
1011        FileWriteLine($SettingsFile, @CRLF & @CRLF)
1012        IniWrite($SettingsFile, "Last Used Adapter", "Name", GUICtrlRead($Adapter))
1013        FileWriteLine($SettingsFile, @CRLF & @CRLF)
1014        IniWrite($SettingsFile, "IPConfig1", "Name", GUICtrlRead($Config1Name))
1015        IniWrite($SettingsFile, "IPConfig1", "IPAddress", GUICtrlRead($IPaddressSet1))
1016        IniWrite($SettingsFile, "IPConfig1", "SubnetMask", GUICtrlRead($SubnetSet1))
1017        IniWrite($SettingsFile, "IPConfig1", "DefaultGW", GUICtrlRead($DefaultGWSet1))
1018        IniWrite($SettingsFile, "IPConfig1","DNS", GUICtrlRead($DNSSet1))
1019        IniWrite($SettingsFile, "IPConfig1","WINS", GUICtrlRead($WINSSet1))
1020        If GUICtrlRead($DHCPCheck1) = $GUI_CHECKED Then
1021                IniWrite($SettingsFile, "IPConfig1", "Use DHCP", "1")
1022        Else
1023                IniWrite($SettingsFile, "IPConfig1", "Use DHCP", "0")
1024        EndIf
1025        FileWriteLine($SettingsFile, @CRLF & @CRLF)
1026        IniWrite($SettingsFile, "IPConfig2", "Name", GUICtrlRead($Config2Name))
1027        IniWrite($SettingsFile, "IPConfig2", "IPAddress", GUICtrlRead($IPaddressSet2))
1028        IniWrite($SettingsFile, "IPConfig2", "SubnetMask", GUICtrlRead($SubnetSet2))
1029        IniWrite($SettingsFile, "IPConfig2", "DefaultGW", GUICtrlRead($DefaultGWSet2))
1030        IniWrite($SettingsFile, "IPConfig2","DNS", GUICtrlRead($DNSSet2))
1031        IniWrite($SettingsFile, "IPConfig2","WINS", GUICtrlRead($WINSSet2))
1032        If GUICtrlRead($DHCPCheck2) = $GUI_CHECKED Then
1033                IniWrite($SettingsFile, "IPConfig2", "Use DHCP", "1")
1034        Else
1035                IniWrite($SettingsFile, "IPConfig2", "Use DHCP", "0")
1036        EndIf
1037        FileWriteLine($SettingsFile, @CRLF & @CRLF)
1038        IniWrite($SettingsFile, "IPConfig3", "Name", GUICtrlRead($Config3Name))
1039        IniWrite($SettingsFile, "IPConfig3", "IPAddress", GUICtrlRead($IPaddressSet3))
1040        IniWrite($SettingsFile, "IPConfig3", "SubnetMask", GUICtrlRead($SubnetSet3))
1041        IniWrite($SettingsFile, "IPConfig3", "DefaultGW", GUICtrlRead($DefaultGWSet3))
1042        IniWrite($SettingsFile, "IPConfig3","DNS", GUICtrlRead($DNSSet3))
1043        IniWrite($SettingsFile, "IPConfig3","WINS", GUICtrlRead($WINSSet3))
1044        If GUICtrlRead($DHCPCheck3) = $GUI_CHECKED Then
1045                IniWrite($SettingsFile, "IPConfig3", "Use DHCP", "1")
1046        Else
1047                IniWrite($SettingsFile, "IPConfig3", "Use DHCP", "0")
1048        EndIf
1049        FileWriteLine($SettingsFile, @CRLF & @CRLF)
1050        IniWrite($SettingsFile, "IPConfig4", "Name", GUICtrlRead($Config4Name))
1051        IniWrite($SettingsFile, "IPConfig4", "IPAddress", GUICtrlRead($IPaddressSet4))
1052        IniWrite($SettingsFile, "IPConfig4", "SubnetMask", GUICtrlRead($SubnetSet4))
1053        IniWrite($SettingsFile, "IPConfig4", "DefaultGW", GUICtrlRead($DefaultGWSet4))
1054        IniWrite($SettingsFile, "IPConfig4","DNS", GUICtrlRead($DNSSet4))
1055        IniWrite($SettingsFile, "IPConfig4","WINS", GUICtrlRead($WINSSet4))
1056        If GUICtrlRead($DHCPCheck4) = $GUI_CHECKED Then
1057                IniWrite($SettingsFile, "IPConfig4", "Use DHCP", "1")
1058        Else
1059                IniWrite($SettingsFile, "IPConfig4", "Use DHCP", "0")
1060        EndIf
1061
1062        FileWriteLine($SettingsFile, @CRLF & @CRLF)
1063        IniWrite($SettingsFile, "IPConfig5", "Name", GUICtrlRead($Config5Name))
1064        IniWrite($SettingsFile, "IPConfig5", "IPAddress", GUICtrlRead($IPaddressSet5))
1065        IniWrite($SettingsFile, "IPConfig5", "SubnetMask", GUICtrlRead($SubnetSet5))
1066        IniWrite($SettingsFile, "IPConfig5", "DefaultGW", GUICtrlRead($DefaultGWSet5))
1067        IniWrite($SettingsFile, "IPConfig5","DNS", GUICtrlRead($DNSSet5))
1068        IniWrite($SettingsFile, "IPConfig5","WINS", GUICtrlRead($WINSSet5))
1069        If GUICtrlRead($DHCPCheck5) = $GUI_CHECKED Then
1070                IniWrite($SettingsFile, "IPConfig5", "Use DHCP", "1")
1071        Else
1072                IniWrite($SettingsFile, "IPConfig5", "Use DHCP", "0")
1073        EndIf
1074EndFunc