Jump to content
Sign in to follow this  
Osixs

Problem with _GUICtrlListView_AddSubItem

Recommended Posts

Osixs

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.

Share this post


Link to post
Share on other sites
Authenticity

$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

Share this post


Link to post
Share on other sites
Osixs

Thank you for your reply but it does not work >_

Share this post


Link to post
Share on other sites
Authenticity

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 by Authenticity

Share this post


Link to post
Share on other sites
Osixs

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.

Share this post


Link to post
Share on other sites
Osixs

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.

Share this post


Link to post
Share on other sites
Osixs

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.

Share this post


Link to post
Share on other sites
Authenticity

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 by Authenticity

Share this post


Link to post
Share on other sites
Osixs

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.

Share this post


Link to post
Share on other sites
Authenticity

$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

Share this post


Link to post
Share on other sites
Osixs

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:

Posted Image

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.

Share this post


Link to post
Share on other sites
Authenticity

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.

Share this post


Link to post
Share on other sites
Osixs

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×