Osixs Posted August 10, 2009 Share Posted August 10, 2009 Hello all >_< My script consists to take all the ips of the local or remote machine and to display in a _GUICtrlListView_AddSubItem. But when I have more ips on the pc or I see it as the latest find. How to display IP1, IP2, IP3 in _GUICtrlListView_AddSubItem. ? that's my code: $colItemsNetwork = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL") $y = _GUICtrlListView_GetItemCount($ListView1) ; Add Ip Address info For $objItem In $colItemsNetwork If ($objItem.IPAddress) <> "0.0.0.0" Then For $o = 0 To UBound($objItem.IPAddress) $getipadd = $objItem.IPAddress(0) Next EndIf _GUICtrlListView_AddSubItem($ListView1, $y, $getipadd, 2, 3) Next ; End Ip Adress info Thank you in advance. Good day. Link to comment Share on other sites More sharing options...
Authenticity Posted August 10, 2009 Share Posted August 10, 2009 $objWMIService = ObjGet('winmgmts:\\.\root\CIMV2') $colItemsNetwork = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE", "WQL") ; Add Ip Address info For $objItem In $colItemsNetwork If IsArray($objItem.IPAddress) And ($objItem.IPAddress(0) <> "0.0.0.0") Then _ _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1), $objItem.IPAddress(0), 2, 3) Next ; End Ip Adress info Link to comment Share on other sites More sharing options...
Osixs Posted August 11, 2009 Author Share Posted August 11, 2009 Thank you for your reply but it does not work >_ Link to comment Share on other sites More sharing options...
Authenticity Posted August 11, 2009 Share Posted August 11, 2009 (edited) What do you want it to do? You want the IP addresses to fit each in a new row or each in an increased column? $objWMIService = ObjGet('winmgmts:\\.\root\CIMV2') $colItemsNetwork = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE", "WQL") ; Add Ip Address info For $objItem In $colItemsNetwork Local $iRow = _GUICtrlListView_AddItem($hListView1, 'Text') Local $iColumn = 1 If IsArray($objItem.IPAddress) Then For $i = 0 To UBound($objItem.IPAddress)-1 If $objItem.IPAddress($i) <> "0.0.0.0" Then _GUICtrlListView_AddSubItem($hListView1, $iRow, $objItem.IPAddress($i), $iColumn) $iColumn += 1 EndIf Next EndIf Next Edited August 11, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Osixs Posted August 11, 2009 Author Share Posted August 11, 2009 Thanks for your reply. I want all my ip ( 3 ) in One ROW exemple: IP1, IP2, IP3 in the same row Thank you in advance. Good day. Link to comment Share on other sites More sharing options...
Osixs Posted August 12, 2009 Author Share Posted August 12, 2009 Hello all >_< i have test with: _ArrayToString but i have allways the same ip address in my row ; Add Ip Address info For $objItem In $colItemsNetwork If ($objItem.IPAddress) <> "0.0.0.0" Then For $o = 0 To UBound($objItem.IPAddress) $getipa[$o] = $objItem.IPAddress(0) _GUICtrlListView_AddSubItem($ListView1, $y, _ArrayToString($getipa, " ", 0, 7), 2, 3) Next EndIf Next ; End Ip Adress info Thank you in advance. Good day. Link to comment Share on other sites More sharing options...
Osixs Posted August 13, 2009 Author Share Posted August 13, 2009 Hello, Here I find the command in vbscript "Join (list [, delimiter])" But I do not know if this exists in AutoIt. Can you help me please? Thank you in advance. Good day. Link to comment Share on other sites More sharing options...
Authenticity Posted August 13, 2009 Share Posted August 13, 2009 (edited) You keep assigning the same element of the object's array to your array. Did you take a look in the code I've posted? Edited August 13, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Osixs Posted August 13, 2009 Author Share Posted August 13, 2009 Thank you for your reply. Yes I looked at your code, which is very good but I Columns created for every ip address. Me I would like to have all my ip addresses in the same row ( case ) is that possible? Thank you in advance. Link to comment Share on other sites More sharing options...
Authenticity Posted August 13, 2009 Share Posted August 13, 2009 $objWMIService = ObjGet('winmgmts:\\.\root\CIMV2') $colItemsNetwork = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE", "WQL") ; Add Ip Address info For $objItem In $colItemsNetwork Local $iRow = _GUICtrlListView_GetItemCount($hListView1)-1 Local $sText = '' If IsArray($objItem.IPAddress) Then For $i = 0 To UBound($objItem.IPAddress)-1 If $objItem.IPAddress($i) <> "0.0.0.0" Then $sText &= $objItem.IPAddress($i) & ' ' EndIf Next _GUICtrlListView_AddSubItem($hListView1, $iRow, $sText, 2, 3) EndIf Next Link to comment Share on other sites More sharing options...
Osixs Posted August 14, 2009 Author Share Posted August 14, 2009 Hello, Thank you very much for your help Authenticity. But I still have a ip address in my case (row) I put a print screen to show you: In the network adapters tab you can see that I have several network interfaces and therefore multiple IP that I would like to put in my box ( row ) ip address.Thank you in advance. Good day to you all. And thank you for your help. Link to comment Share on other sites More sharing options...
Authenticity Posted August 14, 2009 Share Posted August 14, 2009 Hi, if you can see them in the loop it means that each belong to another item in the collection returned from the ExecQuery method. In this can, I guess this would be correct. Though, a little bit of testing would get you there >_<. $objWMIService = ObjGet('winmgmts:\\.\root\CIMV2') $colItemsNetwork = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE", "WQL") Local $iRow = _GUICtrlListView_GetItemCount($hListView1)-1 Local $sText = '' ; Add Ip Address info For $objItem In $colItemsNetwork If IsArray($objItem.IPAddress) Then For $i = 0 To UBound($objItem.IPAddress)-1 If $objItem.IPAddress($i) <> "0.0.0.0" Then $sText &= $objItem.IPAddress($i) & ' ' EndIf Next EndIf Next _GUICtrlListView_AddSubItem($hListView1, $iRow, $sText, 2, 3) ..if no, forgive my innocent assumption. Link to comment Share on other sites More sharing options...
Osixs Posted August 14, 2009 Author Share Posted August 14, 2009 Authenticity thank you very much for your help and your very efficasse speed and quality of response:) I just modify the code for the IPV4 Local $iRow = _GUICtrlListView_GetItemCount($ListView1)-1 Local $sText = '' ; Add Ip Address info For $objItem In $colItemsNetwork If IsArray($objItem.IPAddress) Then For $i = 0 To UBound($objItem.IPAddress(0)) If $objItem.IPAddress(0) <> "0.0.0.0" Then $sText &= $objItem.IPAddress(0) & ' ' EndIf Next EndIf Next _GUICtrlListView_AddSubItem($ListView1, $iRow, $sText, 2, 3) I thank you and wish you a good day. 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