Jump to content


 

Display IP Address, Default Gateway & DNS Servers


58 replies to this topic

#41 guinness

    guinness

  • AutoIt MVPs (MVP)
  • 4,993 posts
  • Gender:Not Telling

Posted 16 May 2011 - 01:44 PM

Quote

The numbers should be: Description [0], IP Address [1], Default Gateway [3], DNS Servers [4], Mac [2], Obtain DNS Automatically [5].
OK, thanks I changed all my Examples in this thread. It was a simple mistake that I overlooked.

Quote

I have looked into using Global and Local instead of Dim but, to be honest, it seems like too much of a learning curve for me right now.
This does concern me a little because I take it you are getting paid by your customers for this Script? Messing with Network Adapters settings isn't for the novice coder or the faint hearted.

Quote

I even tried to add another WMIRegRead line but, it didn't like 2 lines of WMIRegRead or, it would only read one but, not both.

How can we add "Obtain IP Address Automatically" and show in the message box right above "Obtain DNS Server Automatically"?
I was kind of hoping you would learn from the Example and integrate into your version :)

Is this what you were looking for? >>
[ autoIt ]    ( ExpandCollapse - Popup )
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <Array.au3> Global $aArray = _IPDetails(), $sData _ArrayDisplay($aArray) For $A = 1 To $aArray[0][0]     $sData &= "Description: " & $aArray[$A][0] & @CRLF & "IP Address: " & $aArray[$A][1] & @CRLF & "MAC: " & $aArray[$A][2] & _             @CRLF & "Default Gateway: " & $aArray[$A][3] & @CRLF & "DNS Servers: " & $aArray[$A][4] & @CRLF & "Obtain DNS Automatically: " & $aArray[$A][5] & _             @CRLF & "Auto IP: " & $aArray[$A][6] & @CRLF & @CRLF Next $sData = StringTrimRight($sData, 4) MsgBox(0, "_IPDetails()", $sData) Func _IPDetails()     Local $iCount = 0     Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")     Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[1][7] = [[0, 7]]     If IsObj($oColItems) Then         For $oObjectItem In $oColItems             $aReturn[0][0] += 1             $iCount += 1             If $aReturn[0][0] <= $iCount + 1 Then                 ReDim $aReturn[$aReturn[0][0] * 2][$aReturn[0][1]]             EndIf             $aReturn[$iCount][0] = _IsString($oObjectItem.Description)             $aReturn[$iCount][1] = _IsString($oObjectItem.IPAddress(0))             $aReturn[$iCount][2] = _IsString($oObjectItem.MACAddress)             $aReturn[$iCount][3] = _IsString($oObjectItem.DefaultIPGateway(0))             $aReturn[$iCount][4] = _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ") ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking.             $aReturn[$iCount][5] = _WMIRegRead($oObjectItem.SettingID)             $aReturn[$iCount][6] = _IsString($oObjectItem.DHCPEnabled)         Next         ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1]]         Return $aReturn     EndIf     Return SetError(1, 0, $aReturn) EndFunc   ;==>_IPDetails Func _WMIRegRead($iGUID)     If RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $iGUID & "\", "NameServer") = "" Then         Return True     EndIf     Return False EndFunc   ;==>_WMIRegRead Func _IsString($sString)     If IsString($sString) Or IsBool($sString) Then         Return $sString     EndIf     Return "Not Available" EndFunc   ;==>_IsString Func _WMIArrayToString($aArray, $sDelimeter = "|")     If IsArray($aArray) = 0 Then         Return SetError(1, 0, "Not Available")     EndIf     Local $iUbound = UBound($aArray) - 1, $sString     For $A = 0 To $iUbound         $sString &= $aArray[$A] & $sDelimeter     Next     Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc   ;==>_WMIArrayToString

Example List: _AdapterConnections()_BinaryBin()_CheckMsgBox_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_FileCompare()_FileCompareContents()_FileNameByHandle()_FindInFile()_GetBackgroundColor() & _SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename() & _GetFilenameExt()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsUPX()_IsValidType()_Language()_Log()_MSDNDataType()_PathFull/GetRelative/Split()_ProgressSetMarquee()_ReDim()_ScrollingCredits_SelfDelete()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_Startup()_StringIsValid()_Temperature()_TrialPeriod()_UKToUSDate() & _USToUKDate()_WMIDateStringToDate() & _DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()FileInstallrGUI - Only Close ButtonGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore...
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image




#42 wowmarkb

    Member

  • Full Members
  • Pip
  • 52 posts

Posted 17 May 2011 - 01:47 AM

Guinness - Thanks, it works great.

This little tool will help my customers complete the tasks in the book I am writing about fixing your Internet connection.

I tried to add to your last script- I just kept getting too many errors.

Thanks again.

#43 guinness

    guinness

  • AutoIt MVPs (MVP)
  • 4,993 posts
  • Gender:Not Telling

Posted 17 May 2011 - 10:57 AM

What was the error because this worked on Windows XP SP3 & Windows 7 x64?

Edited by guinness, 17 May 2011 - 10:58 AM.

Example List: _AdapterConnections()_BinaryBin()_CheckMsgBox_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_FileCompare()_FileCompareContents()_FileNameByHandle()_FindInFile()_GetBackgroundColor() & _SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename() & _GetFilenameExt()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsUPX()_IsValidType()_Language()_Log()_MSDNDataType()_PathFull/GetRelative/Split()_ProgressSetMarquee()_ReDim()_ScrollingCredits_SelfDelete()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_Startup()_StringIsValid()_Temperature()_TrialPeriod()_UKToUSDate() & _USToUKDate()_WMIDateStringToDate() & _DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()FileInstallrGUI - Only Close ButtonGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore...
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image


#44 wowmarkb

    Member

  • Full Members
  • Pip
  • 52 posts

Posted 17 May 2011 - 05:12 PM

guinness, the script on this forum page (page 3) works fine, no errors.

I am now trying to put it into the previous script (the one with the GUI and all the buttons) and make the "Check Addresses" button when pressed, run this latest script.

Last night I removed some old lines we had about description, IP Address, etc. from the GUI script but, it either opened a blank window or, this new message window opened without waiting for a button press.

So, I need to link the lines about button press of the GUI script to this new script for this new message window to open.

After I get home from work, I should be able to get it all working together since I am getting an education on what the lines of code are doing. FYI- I work at a Cable TV/Internet provider and help people get back on the Internet.

#45 guinness

    guinness

  • AutoIt MVPs (MVP)
  • 4,993 posts
  • Gender:Not Telling

Posted 17 May 2011 - 06:09 PM

OK so you do you know a bit then :D

If you add and have a problem then post here. But of course I think you get the idea of what to do.

Example List: _AdapterConnections()_BinaryBin()_CheckMsgBox_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_FileCompare()_FileCompareContents()_FileNameByHandle()_FindInFile()_GetBackgroundColor() & _SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename() & _GetFilenameExt()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsUPX()_IsValidType()_Language()_Log()_MSDNDataType()_PathFull/GetRelative/Split()_ProgressSetMarquee()_ReDim()_ScrollingCredits_SelfDelete()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_Startup()_StringIsValid()_Temperature()_TrialPeriod()_UKToUSDate() & _USToUKDate()_WMIDateStringToDate() & _DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()FileInstallrGUI - Only Close ButtonGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore...
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image


#46 wowmarkb

    Member

  • Full Members
  • Pip
  • 52 posts

Posted 17 May 2011 - 07:01 PM

I can understand some of what is in the script. Like MsgBox- I have played with settings so I know how to change appearance, the GUI- size and placemwent, colors, button press action- but how to make it read the IP Address and then put it in a message box- that's where I needed help.

Now that I have your script I can kinda see how it works. Before, you had a Dim statment- I read up on that and now, this version has array statements so, a little differrent.

#47 guinness

    guinness

  • AutoIt MVPs (MVP)
  • 4,993 posts
  • Gender:Not Telling

Posted 17 May 2011 - 07:59 PM

I don't use Dim ever, only Local & Global. If I have to resize the Array I use ReDim, but I make sure this isn't done everytime in a loop. Also my Examples labeled 1 through 3 have stayed pretty much the same.

Have you thought about using @IPAddress in a MsgBox()?

Edited by guinness, 17 May 2011 - 07:59 PM.

Example List: _AdapterConnections()_BinaryBin()_CheckMsgBox_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_FileCompare()_FileCompareContents()_FileNameByHandle()_FindInFile()_GetBackgroundColor() & _SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename() & _GetFilenameExt()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsUPX()_IsValidType()_Language()_Log()_MSDNDataType()_PathFull/GetRelative/Split()_ProgressSetMarquee()_ReDim()_ScrollingCredits_SelfDelete()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_Startup()_StringIsValid()_Temperature()_TrialPeriod()_UKToUSDate() & _USToUKDate()_WMIDateStringToDate() & _DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()FileInstallrGUI - Only Close ButtonGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore...
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image


#48 wowmarkb

    Member

  • Full Members
  • Pip
  • 52 posts

Posted 18 May 2011 - 03:09 AM

If I remember correctly, back in 2008 when I started playing with this little tool, the @IPAddress did not accurately give the current IP. I forget how I came across this but, I wanted to find another way. (I think I set some static ip address and it could read it correctly.)

#49 guinness

    guinness

  • AutoIt MVPs (MVP)
  • 4,993 posts
  • Gender:Not Telling

Posted 18 May 2011 - 10:26 AM

AutoIt has been updated quite a bit since 2008 :D

Example List: _AdapterConnections()_BinaryBin()_CheckMsgBox_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_FileCompare()_FileCompareContents()_FileNameByHandle()_FindInFile()_GetBackgroundColor() & _SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename() & _GetFilenameExt()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsUPX()_IsValidType()_Language()_Log()_MSDNDataType()_PathFull/GetRelative/Split()_ProgressSetMarquee()_ReDim()_ScrollingCredits_SelfDelete()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_Startup()_StringIsValid()_Temperature()_TrialPeriod()_UKToUSDate() & _USToUKDate()_WMIDateStringToDate() & _DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()FileInstallrGUI - Only Close ButtonGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore...
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image


#50 briandoc

    Newbie

  • Members
  • 4 posts

Posted 19 January 2012 - 04:47 PM

I came across this while looking for some examples on getting an accurate IP address (since AutoIT documentation for even the most current version still says "@IPADDRESS tends to return 127.0.0.1 on some computers", which is unacceptable).

I have to say that the experts on this forum certainly bend over backwards for posters who are looking to be taught and have their code written and re-written for them and modified to add functionality etc. I could never handle doing someone's work for them. I think it's one thing to ask for a snippet of code or an example or a reference, but basically asking someone to do their job for them because they are just too frazzled to understand basic code or to dive in and learn the basics and progress like the rest of us through trial/error and searching for answers is really unbelieveable.

Hats off to guinness and the others for their patience and generosity.

#51 JLogan3o13

    Mass Spammer!

  • Full Members
  • PipPipPipPipPip
  • 712 posts
  • Gender:Male
  • Location:Michigan

Posted 19 January 2012 - 04:52 PM

You resurrected an eight month old post for that?
J.

I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.

#52 briandoc

    Newbie

  • Members
  • 4 posts

Posted 19 January 2012 - 05:03 PM

View PostJLogan3o13, on 19 January 2012 - 04:52 PM, said:

You resurrected an eight month old post for that?

Yes.

If it had been 8 years old, I would have done the same. It doesn't matter hold old a post is, if something needs to be said that wasn't said 8 months ago, I could care less if you were inconvenienced because the post was resurrected.

Edited by briandoc, 19 January 2012 - 05:06 PM.


#53 guinness

    guinness

  • AutoIt MVPs (MVP)
  • 4,993 posts
  • Gender:Not Telling

Posted 21 January 2012 - 11:18 PM

I'm certainly not the best believe you me, but if I learn during the process then I'm happy to help and this was a perfect example of why I helped @wowmarkb.

Example List: _AdapterConnections()_BinaryBin()_CheckMsgBox_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_FileCompare()_FileCompareContents()_FileNameByHandle()_FindInFile()_GetBackgroundColor() & _SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename() & _GetFilenameExt()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsUPX()_IsValidType()_Language()_Log()_MSDNDataType()_PathFull/GetRelative/Split()_ProgressSetMarquee()_ReDim()_ScrollingCredits_SelfDelete()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_Startup()_StringIsValid()_Temperature()_TrialPeriod()_UKToUSDate() & _USToUKDate()_WMIDateStringToDate() & _DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()FileInstallrGUI - Only Close ButtonGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore...
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image


#54 tletourneau

    Newbie

  • Members
  • 4 posts
  • Gender:Male
  • Location:MN

Posted 03 February 2012 - 11:14 PM

First I'd like to thank everyone that has worked on this code! I was looking for something just like this. I have two questions. The first question is: when I run the code I get an array box that opens and when I close that I get the message window with the data. Is there a way to supress the array window and just have the message window open? Also, is it possible to have the text in the message box selectable so it could be copied and pasted? Here is the code I'm working with:

[ code='text' ]    ( ExpandCollapse - Popup )
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <Array.au3> Global $aArray = _IPDetails(), $sData _ArrayDisplay($aArray) For $A = 1 To $aArray[0][0]     $sData &= "Description: " & $aArray[$A][0] & @CRLF & "IP Address: " & $aArray[$A][1] & @CRLF & "MAC: " & _             $aArray[$A][2] & @CRLF & "Default Gateway: " & $aArray[$A][3] & @CRLF & "DNS Servers: " & $aArray[$A][4] & @CRLF & @CRLF Next $sData = StringTrimRight($sData, 4) MsgBox(0, "_IPDetails()", $sData) Func _IPDetails()     Local $iCount = 0     Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")     Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[1][5] = [[0, 5]]     If IsObj($oColItems) Then         For $oObjectItem In $oColItems             $aReturn[0][0] += 1             $iCount += 1             If $aReturn[0][0] <= $iCount + 1 Then                 ReDim $aReturn[$aReturn[0][0] * 2][$aReturn[0][1]]             EndIf             $aReturn[$iCount][0] = _IsString($oObjectItem.Description)             $aReturn[$iCount][1] = _IsString($oObjectItem.IPAddress(0))             $aReturn[$iCount][2] = _IsString($oObjectItem.MACAddress)             $aReturn[$iCount][3] = _IsString($oObjectItem.DefaultIPGateway(0))             $aReturn[$iCount][4] = _IsString(_WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ")) ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking.         Next         ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1]]         Return $aReturn     EndIf     Return SetError(1, 0, $aReturn) EndFunc   ;==>_IPDetails Func _IsString($sString)     If IsString($sString) Then         Return $sString     EndIf     Return "Not Available" EndFunc   ;==>_IsString Func _WMIArrayToString($aArray, $sDelimeter = "|")     If IsArray($aArray) = 0 Then         Return SetError(1, 0, "Not Available")     EndIf     Local $iUbound = UBound($aArray) - 1, $sString     For $A = 0 To $iUbound         $sString &= $aArray[$A] & $sDelimeter     Next     Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc   ;==>_WMIArrayToString

Any and all help will be greatly appreciated! I'm not a coder but I'm starting to learn.

Thanks,

Tom

#55 Robjong

    Spammer!

  • Full Members
  • PipPipPip
  • 268 posts
  • Gender:Not Telling
  • Location:The Netherlands

Posted 03 February 2012 - 11:35 PM

Hi,

Yes, just comment the _ArrrayDisplay line, to be able to select the text you will have to make your own GUI as far I know.
[ autoIt ]    ( ExpandCollapse - Popup )
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $aArray = _IPDetails(), $sData, $nMsg, $hButtonClose ;~ _ArrayDisplay($aArray) For $A = 1 To $aArray[0][0]     $sData &= "Description: " & $aArray[$A][0] & @CRLF & "IP Address: " & $aArray[$A][1] & @CRLF & "MAC: " & _             $aArray[$A][2] & @CRLF & "Default Gateway: " & $aArray[$A][3] & @CRLF & "DNS Servers: " & $aArray[$A][4] & @CRLF & @CRLF Next $sData = StringTrimRight($sData, 4) GUICreate("IP Details", 400, 260) ; create GUI GUICtrlCreateEdit($sData, 8, 8, 384, 204, BitOR($ES_READONLY, $ES_WANTRETURN), 0) ; place an edit on there $hButtonClose = GUICtrlCreateButton("&OK", 150, 224, 100, 28) ; and a button to close the window GUISetState() While 1 ; keeps script running until window is closed     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE ; window is closed the default way             Exit         Case $hButtonClose ; user clicked on the button             Exit     EndSwitch     Sleep(50) WEnd MsgBox(0, "_IPDetails()", $sData) Func _IPDetails()     Local $iCount = 0     Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")     Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[1][5] = [[0, 5]]     If IsObj($oColItems) Then         For $oObjectItem In $oColItems             $aReturn[0][0] += 1             $iCount += 1             If $aReturn[0][0] <= $iCount + 1 Then                 ReDim $aReturn[$aReturn[0][0] * 2][$aReturn[0][1]]             EndIf             $aReturn[$iCount][0] = _IsString($oObjectItem.Description)             $aReturn[$iCount][1] = _IsString($oObjectItem.IPAddress(0))             $aReturn[$iCount][2] = _IsString($oObjectItem.MACAddress)             $aReturn[$iCount][3] = _IsString($oObjectItem.DefaultIPGateway(0))             $aReturn[$iCount][4] = _IsString(_WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ")) ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking.         Next         ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1]]         Return $aReturn     EndIf     Return SetError(1, 0, $aReturn) EndFunc   ;==>_IPDetails Func _IsString($sString)     If IsString($sString) Then         Return $sString     EndIf     Return "Not Available" EndFunc   ;==>_IsString Func _WMIArrayToString($aArray, $sDelimeter = "|")     If IsArray($aArray) = 0 Then         Return SetError(1, 0, "Not Available")     EndIf     Local $iUbound = UBound($aArray) - 1, $sString     For $A = 0 To $iUbound         $sString &= $aArray[$A] & $sDelimeter     Next     Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc   ;==>_WMIArrayToString

Edit: cleaning, also updated the script to address your second question

Edited by Robjong, 04 February 2012 - 12:01 AM.


#56 tletourneau

    Newbie

  • Members
  • 4 posts
  • Gender:Male
  • Location:MN

Posted 04 February 2012 - 12:56 AM

That is perfect, thank you! I was able to see the changes you made, that helps a lot too.

Edited by tletourneau, 04 February 2012 - 12:56 AM.


#57 guinness

    guinness

  • AutoIt MVPs (MVP)
  • 4,993 posts
  • Gender:Not Telling

Posted 04 February 2012 - 02:28 AM

So didn't need to change anything?

Example List: _AdapterConnections()_BinaryBin()_CheckMsgBox_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_FileCompare()_FileCompareContents()_FileNameByHandle()_FindInFile()_GetBackgroundColor() & _SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename() & _GetFilenameExt()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsUPX()_IsValidType()_Language()_Log()_MSDNDataType()_PathFull/GetRelative/Split()_ProgressSetMarquee()_ReDim()_ScrollingCredits_SelfDelete()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_Startup()_StringIsValid()_Temperature()_TrialPeriod()_UKToUSDate() & _USToUKDate()_WMIDateStringToDate() & _DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()FileInstallrGUI - Only Close ButtonGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore...
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image


#58 tletourneau

    Newbie

  • Members
  • 4 posts
  • Gender:Male
  • Location:MN

Posted 04 February 2012 - 04:05 AM

Hi guinness, the changes that Robjong made did what I asked in my previous post and it is working as expected. The only thing I'm trying to figure out now is how to have it show all gateways for an adapter, not just the default gateway. I'll take any pointers on that! :)

#59 tletourneau

    Newbie

  • Members
  • 4 posts
  • Gender:Male
  • Location:MN

Posted 09 February 2012 - 01:39 AM

Ok, how would I add the output from win32_IP4PersistedRouteTable (from CIM_LogicalElement or CIM_ManagedSystemElement) to a scrollable table in the output box? I'e tried adding another execquery for the class and adding an isString but that fails. Esentially I'm trying to display the persistent routes in a table under the IP information. Pointers, please...

Thanks,

Tom





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users