jagreenwood Posted November 28, 2007 Share Posted November 28, 2007 Hi Guys, I've got an AutoIt script that installs and configures another app. During the installation process I'm popping up a box with inputbox() for the user to enter the IP address of a server. I haven't been able to figure out a way to validate the input is in an IP address format(xxx.xxx.xxx.xxx). Does anyone have any ideas on how I might be able to accomplish this? Thanks!! Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 28, 2007 Share Posted November 28, 2007 Hi Guys,I've got an AutoIt script that installs and configures another app. During the installation process I'm popping up a box with inputbox() for the user to enter the IP address of a server. I haven't been able to figure out a way to validate the input is in an IP address format(xxx.xxx.xxx.xxx).Does anyone have any ideas on how I might be able to accomplish this?Thanks!!You could apply a bunch of string manipulation, starting with StringSplit($sInputIP, "."), etc.The other option is StringRegExp(), but that requires more experience. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ame1011 Posted November 28, 2007 Share Posted November 28, 2007 \b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\bthats the regular expression to make sure all numbers are between 0 and 255 [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font] Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 28, 2007 Share Posted November 28, 2007 It's not that a good RegExp won't work (and get you Geek Points), but this is easier to read, and easier to add more conditions to: While 1 $sInputIP = InputBox("IP", "Input IP: ") If @error Then ExitLoop $avSplit = StringSplit($sInputIP, ".") If $avSplit[0] = 4 Then For $n = 1 To 4 $Octet = Number($avSplit[$n]) If ($Octet < 0) Or ($Octet > 255) Then ContinueLoop 2 If ($n = 1) And ($Octet = 0) Then ContinueLoop 2 Next ExitLoop EndIf WEnd If $sInputIP <> "" Then MsgBox(64, "Valid IP", $sInputIP) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ptrex Posted November 28, 2007 Share Posted November 28, 2007 @ Why doen't you use a "_GUICtrlIpAddressCreate" ? expandcollapse popup#include <GuiIPAddress.au3> Opt("MustDeclareVars", 1) _Main() Func _Main() Local $msg, $hgui, $clear, $getaddress, $isblank, $button, $hIPAddress $hgui = GUICreate("IP Address Control Create Example", 300, 150) $hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME) $clear = GUICtrlCreateButton("Clear IP", 10, 50, 80, 20) $getaddress = GUICtrlCreateButton("Get IP", 95, 50, 80, 20) $isblank = GUICtrlCreateButton("Is Blank?", 180, 50, 80, 20) $button = GUICtrlCreateButton("Exit", 100, 100, 100, 25) _GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $button Exit Case $msg = $clear _GUICtrlIpAddressClear ($hIPAddress) Case $msg = $getaddress MsgBox(0, "IP Entered", _GUICtrlIpAddressGet ($hIPAddress)) Case $msg = $isblank If _GUICtrlIpAddressIsBlank ($hIPAddress) Then MsgBox(0, "Fields Check", "All IP Fields are blank") Else MsgBox(0, "Fields Check", "NOT All IP Fields are blank") EndIf EndSelect WEnd EndFunc ;==>_Main regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 28, 2007 Share Posted November 28, 2007 That's now _GuiCtrlIPAddress_Create() in the new scheme of things... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
weaponx Posted November 28, 2007 Share Posted November 28, 2007 (edited) It seems like only yesterday someone asked for just such a thing...http://www.autoitscript.com/forum/index.php?showtopic=56285http://www.autoitscript.com/forum/index.ph...c=39932&hl= Edited November 28, 2007 by weaponx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now