;Routine to easily convert IP addresses for DUT's ;Created July,2015 ; Two files are required for this program to work; the exe file and a txt file. ; The text file "PC address.txt" is created for each PC and they cannot be changed. ; The reason is each PC will have its own IP and Subnet addresses. ; This the reason for the PC name on the first line (verify correct PC). ;___________________________________________________________________________________ #include #include #include ;read the text file first to get the addresses: Read_Net_Address() Func Read_Net_Address() ; Create a constant variable in Local scope of the file that will be read/written to. Local Const $sFileName = "PC address.txt" ; Open the file for reading and store the handle to a variable. Local $hFileOpen = FileOpen($sFileName, $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Return False EndIf ; the following is temp only, just till everything is working then will be deleted. ; Read the line of the file for the IP address Local $sPC_Name = FileReadLine($hFileOpen, 1) ; Read the line of the file for the IP address Local $sIP_Address = FileReadLine($hFileOpen, 4) ; Read the line of the file for the Subnet address Local $sSubnet_Address = FileReadLine ($hFileOpen, 7) ; Read the line of the file for the Gateway address Local $sGateway_Address = FileReadLine ($hFileOpen, 10) ; Close the handle returned by FileOpen. FileClose($hFileOpen) ; Display the first line of the file. MsgBox($MB_SYSTEMMODAL, "", "PC Name is: " & $sPC_Name & @CRLF & @CRLF & "IP address is: " & $sIP_Address & @CRLF & @CRLF & "Subnet address is: " & $sSubnet_Address & @CRLF & @CRLF & "Gateway address is: " & $sGateway_Address) EndFunc ;==>Read_Net_Address Network_IP() Func Network_IP() ; Create a GUI with various controls. Local $hGUI = GUICreate("""Default or Crossover"" IP Setup", 320, 175) ; Create all button controls. Local $idDefault_IP = GUICtrlCreateButton("Default IP", 30, 30, 85, 25) Local $idCrossOver_IP = GUICtrlCreateButton ("Crossover IP", 30, 75, 85, 25) Local $idClose = GUICtrlCreateButton("Close", 200,120, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $idDefault_IP ; Reset to the PC default network values goes here ; >>> later update, values to be 'read' from a text ; file instead, this will allow this to be used ; from any PC. <<< ;change code goes here -- ;informed change completed MsgBox (0, "", "Network reset to DEFAULT values","","") Case $idCrossOver_IP ;Reset to the crossover ip values goes here ; >>> later update, values to be 'read' from a text ; file instead, this will allow this to be used ; from any PC. <<< ;change code goes here ;informed change completed MsgBox (0, "", "Network reset to the CROSSOVER values","","") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Network_IP