Jump to content

Can _WM_COMMAND check for a dynamic amount of ListBoxes?


Recommended Posts

This is not a working example -- I'm asking about the principle...

Here we have the often seen code to detect a double-click on an item in one ListBox (ID in $idListBox is of course created by other code).
To catch that ListBox item, I have only added $sBookmark to it. This could be a pick list application.

$idListBox = 0x004A0FB0

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg
    Local   $hWndFrom, $iIDFrom, $iCode, $hWndListBox, _
            $sBookmark

    If Not IsHWnd($idListBox) Then $hWndListBox = GUICtrlGetHandle($idListBox)
    
    $hWndFrom   = $lParam
    $iIDFrom    = BitAND($wParam, 0xFFFF)                                       ; Low Word
    $iCode      = BitShift($wParam, 16)                                         ; Hi Word

    Switch $hWndFrom

        Case $idListBox, $hWndListBox

                $sBookmark = _GUICtrlListBox_GetText( $hWndFrom, _GUICtrlListBox_GetCurSel($hWndFrom) )

                Switch $iCode

                    Case $LBN_DBLCLK

                        ConsoleWrite("you double-clicked " & $sBookmark & @CRLF)

                EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc

 

Now, my question is: can one modify the _WM_COMMAND function to allow for a dynamic number of ListBoxes? (meaning, user-defined -- the amount of ListBoxes/pick lists can change at any time).

Let's assume I dynamically obtained an array with ListBox ID's for (in this case) 5 pick lists:

UxaCpwj.png

One part of the solution seems to work with the For... Next loop I added below, but I'm wondering if that is the ultimate? (knowing this Func has to be as fast as possible)

The part where I can't find anything that works for a dynamic amount of ListBox ID's is in the Case check...

I tried _ArrayToTxt($aIdListBox, ", ", 1), messed with Eval(), and trying Case $aIdListBox[start] To $aIdListBox[end]

 

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg
    Local   $hWndFrom, $iIDFrom, $iCode, $hWndListBox, _
            $sBookmark

    For $i = 1 To UBound($aIdListBox) - 1                       ; is this solution fast enough? (it seems to work well)
        If Not IsHWnd($aIdListBox[$i]) Then
            $hWndListBox = GUICtrlGetHandle($aIdListBox[$i])
            ExitLoop                                            ; cause there can only be one hit(?)
        EndIf
    Next

    $hWndFrom   = $lParam
    $iIDFrom    = BitAND($wParam, 0xFFFF)                       ; Low Word
    $iCode      = BitShift($wParam, 16)                         ; Hi Word

    Switch $hWndFrom

            Case [WHAT TO PUT HERE if nr of ListBoxes is dynamic?], $hWndListBox    ; <=  MAIN question

                $sBookmark = _GUICtrlListBox_GetText( $hWndFrom, _GUICtrlListBox_GetCurSel($hWndFrom) )

                Switch $iCode

                    Case $LBN_DBLCLK

                        ConsoleWrite("you double-clicked " & $sBookmark & @CRLF)
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc

- - -

As a workaround, I can probably add the maximum number of allowed ListBoxes to the Case check, seperated by commas, but only display the number of ListBoxes needed. But I'm hoping it can be made truly dynamical...?

Thank You : )

 

Edited by Guy_
Link to post
Share on other sites

You can make it really dynamic by using a dictionary object to store the lisbox handles instead of an array:

; Create dictionary object
$oListboxDict = ObjCreate( "Scripting.Dictionary" )

; Add listboxes to $oListboxDict
$oListboxDict( $ListboxHandle11 ) = 1
$oListboxDict( $ListboxHandle12 ) = 1
$oListboxDict( $ListboxHandle13 ) = 1
$oListboxDict( $ListboxHandle14 ) = 1
$oListboxDict( $ListboxHandle15 ) = 1

; In _WM_COMMAND use an If ... EndIf instead of a Switch ... EndSwitch
If $oListboxDict.Exists( $hWndFrom ) Then
    ...
    ...
    ...
EndIf

Here you do not need a loop in _WM_COMMAND function.

Link to post
Share on other sites

Awesome!  Thanks a bunch, Larsj :)

Objects in AutoIt are new to me, but at first sight it seemed easy enough. Yet, after double-clicking an item, I'm getting a crash on ...

If $oListboxDict.Exists( $hWndFrom )

What I have done in preparation (simplified) (I'm using $aIdListbox for other purposes too) ... :

Global $oListboxDict, $aIdListbox

Func _CreateListboxes()

    $oListboxDict = ObjCreate("Scripting.Dictionary")

    For $i = 1 To $NrOfLists
        $aIdListbox[$i] = _GUICtrlListBox_Create( ... )
        $oListboxDict( $aIdListbox[$i] ) = 1                    ; add Listbox ID's to dictionary
    Next
    ; (more creation code)
EndFunc

I'm not sure how to replace the For...Next loop, but I hoped I at least placed the If... condition like you suggested...?

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    
    #forceref $hWnd, $iMsg
    Local   $hWndFrom, $iIDFrom, $iCode, $hWndListBox, _
            $_bookmark

    For $i = 1 To UBound($aIdListbox) - 1                                       ; loop ok, or replace how?
        If Not IsHWnd($aIdListbox) Then
            $hWndListBox = GUICtrlGetHandle($aIdListbox)
            ExitLoop
        EndIf
    Next

    $hWndFrom   = $lParam
    $iIDFrom    = BitAND($wParam, 0xFFFF)
    $iCode      = BitShift($wParam, 16)

    If $oListboxDict.Exists( $hWndFrom ) And $hWndListBox Then                  ; CRASHES on $oListboxDict.Exists

        $_bookmark = _GUICtrlListBox_GetText( $hWndFrom, _GUICtrlListBox_GetCurSel($hWndFrom) )

        Switch $iCode
            Case $LBN_DBLCLK
                ConsoleWrite("you double-clicked " & $_bookmark & @CRLF)
        EndSwitch
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc

 

Link to post
Share on other sites

Please show some executable code that works when the GUIRegisterMsg command is commented out, and I'll look into the problem.

Link to post
Share on other sites

Guy_,

Note the use of "number" and "hwnd"...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <array.au3>

Local $NumListBoxes = 5
$oLBH = ObjCreate("Scripting.Dictionary")

Local $gui010 = GUICreate('LB Dictionary Example', 600, 200)

For $1 = 0 To $NumListBoxes - 1
    $oLBH.add(Number(_GUICtrlListBox_Create($gui010, '', $1 * 105 + 40, 10, 100, 100)), $1)
    $akeys = $oLBH.keys
    ;_arraydisplay($akeys)
    For $2 = 1 To $NumListBoxes
        _GUICtrlListBox_AddString(HWnd($akeys[$1]), $1 & '-' & $2)
    Next
Next

GUISetState()

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    If $oLBH.exists(Number($lParam)) And _WinAPI_HiWord($wParam) = $lbn_selchange Then _
            ConsoleWrite('listbox #' & $oLBH.item(Number($lParam)) & ' actioned' & ' Value = ' & _GUICtrlListBox_GetText($lParam, _GUICtrlListBox_GetCurSel($lParam)) & @CRLF)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to post
Share on other sites
18 hours ago, LarsJ said:

Please show some executable code that works when the GUIRegisterMsg command is commented out, and I'll look into the problem.

Not sure what you mean, but seems I would have to make an almost working example? That would take quite some time and luckily I got it working now using Kylomas contribution :)  But I thoroughly appreciate your help in the past and future :sweating:

14 hours ago, kylomas said:

Note the use of "number" and "hwnd"...

I had to burn some grey matter here, but I got it working in the end. It's a thing of beauty :drool:   Thanks so much!

- - - - - - -

I have 2 final questions related to this ...

(1) If I want to include modifier key detection, can I use the (working) code below, or do I need something more professional for this type of function?
IIRC, it  turns out I can not put these detections in the targetted _findBookmark() function, because then WM_COMMAND behaves differently.

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    $_modKey = ""

    If _IsPressed("11") And _IsPressed("10") Then
        $_modKey = "Ctrl+Shift"
    ElseIf _IsPressed("11") Then
        $_modKey = "Ctrl"
    ElseIf _IsPressed("10") Then
        $_modKey = "Shift"
    EndIf   

    If $oLBH.exists(Number($lParam)) And _WinAPI_HiWord($wParam) = $LBN_DBLCLK Then
    
        $_Bookmark  = _GUICtrlListBox_GetText($lParam, _GUICtrlListBox_GetCurSel($lParam))
        $_ListboxNr = $oLBH.item( Number($lParam) )
        
        _findBookmark($_Bookmark, $_modKey, $_ListboxNr)    
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

(2) And to be 100% sure... Am I right that, similar to MouseUp, a KeyUp kinda thing does not exist? (and therefore you see the _IsPressed loops instead?)

An example would be if I would use the Alt key and would arrive in a WordPad file. The Alt_down puts WordPad in a specific mode and crashes my program, so I'm not using Alt (or I could put a loop in _findBookmark() till it's up again). A KeyUp function could solve this easier or earlier  :)

Thank You both again!  :)

Edited by Guy_
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By RAMzor
      Hello all,
      I am trying to get scrolling events for ListBox (mouse wheel and up/down arrows) but without success. The event not occured on row change but if I click on it - yes
      The ComboBox works fine even if not in focus (with mouse wheel) but I prefer visual look of ListBox. In addition to all, I can't change the height of control. Unfortunately it depends only on font size and same fonts has different heights between InputBox and ComboBox
      Is there a way to get over the issue?
      Any other ideas for unit selection realization are welcome
      #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListBoxConstants.au3> Global $idCombo, $idComboUnit, $idList, $idListUnit Global $sComboInitUnit = "pJ", $fComboVal = 7.5 Global $sListInitUnit = "nF", $fListVal = 0.15 Units_Conversion_Example() Func Units_Conversion_Example() ; Create GUI GUICreate("Units Conversion", 400, 296) $idCombo = GUICtrlCreateInput($fComboVal, 22, 20, 91, 26) GUICtrlSetFont(-1, 13, 400, 0, "MS Reference Sans Serif") $idComboUnit = GUICtrlCreateCombo("", 112, 20, 50, 30) GUICtrlSetData(-1, "uJ|nJ|pJ", $sComboInitUnit) GUICtrlSetFont(-1, 13, 400, 0, "MS Reference Sans Serif") $idList = GUICtrlCreateInput($fListVal, 22, 80, 91, 26) GUICtrlSetFont(-1, 13, 400, 0, "MS Reference Sans Serif") $idListUnit = GUICtrlCreateList("", 112, 80, 57, 26, BitOR($LBS_NOTIFY,$LBS_NOSEL,$WS_VSCROLL)) GUICtrlSetData(-1, "uF|nF|pF", $sListInitUnit) GUICtrlSetFont(-1, 13, 400, 0, "MS Reference Sans Serif") GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Do Sleep(5) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo, $hWndListBox If Not IsHWnd($idComboUnit) Then $hWndCombo = GUICtrlGetHandle($idComboUnit) If Not IsHWnd($idListUnit) Then $hWndListBox = GUICtrlGetHandle($idListUnit) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $hWndCombo Switch $iCode Case $LBN_SELCHANGE ConsoleWrite(GUICtrlRead($idComboUnit) & @CRLF) EndSwitch Case $hWndListBox Switch $iCode Case $CBN_SELCHANGE ConsoleWrite(GUICtrlRead($idListUnit) & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND  
       
    • By Dan_555
      Hi, here are few functions for the ListBox.
      I have searched the forum, but most of the functions are for listview, so i took one example code from melba23 (clear selection) and
      wrote few more functions. (Because my current project needs them).
       
      These functions work only on a Multi-selection ListBox . 
      Edit: Only 1 function does not work with single selection box.
      The functions do: Clear Selection, Delete Selected items, Invert Selection, Move selected items up and down.
       The example code has 2 Listboxes. The selected items on the left ListBox can be moved up and down. The right Listbox has buttons for the other functions.
      #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> Local $singlesel = 0, $iMsgBoxAnswer = 0 ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Question, Modality=Task Modal $iMsgBoxAnswer = MsgBox(8228, "Choose Listbox selecton type", "Yes for single, No for multi selection box") If $iMsgBoxAnswer = 6 Then $singlesel = 1 ;Yes Local $BL_1,$BL_2,$BR_1,$BR_2,$BR_3,$BR_4,$BR_5,$BR_6 Global $hForm1 = GUICreate("Listbox test", 349, 287) $LB_1 = GUICtrlCreateList("", 6, 40, 157, 244, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) If $singlesel = 1 Then $LB_2 = GUICtrlCreateList("", 179, 40, 157, 244, BitOR($LBS_NOTIFY, $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) Else $LB_2 = GUICtrlCreateList("", 179, 40, 157, 244, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) $BR_3 = GUICtrlCreateButton("Reverse Sel", 272, 22, 68, 17) EndIf $BL_1 = GUICtrlCreateButton("Up", 20, 3, 35, 18) $BL_2 = GUICtrlCreateButton("Down", 60, 3, 35, 18) $BR_1 = GUICtrlCreateButton("Up", 200, 3, 35, 18) $BR_2 = GUICtrlCreateButton("Down", 240, 3, 35, 18) $BR_4 = GUICtrlCreateButton("Clear Sel", 217, 22, 52, 17) $BR_5 = GUICtrlCreateButton("Delete", 175, 22, 40, 17) $BR_6 = GUICtrlCreateButton("Populate", 290, 3, 50, 18) GUISetState(@SW_SHOW) For $x = 0 To 50 If $x <= 10 Then GUICtrlSetData($LB_1, $x & " test", 0) GUICtrlSetData($LB_2, $x & " Test", 0) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BL_1 $a = Listbox_ItemMoveUD($LB_1, -1) If $a > -1 Then WinSetTitle($hForm1, "", "Moved items: " & $a) Case $BL_2 $a = Listbox_ItemMoveUD($LB_1, 1) If $a > -1 Then WinSetTitle($hForm1, "", "Moved items: " & $a) Case $BR_1 Listbox_ItemMoveUD($LB_2, -1) Case $BR_2 Listbox_ItemMoveUD($LB_2, 1) Case $BR_3 Listbox_ReverseSelection($LB_2) Case $BR_4 Listbox_ClearSelection($LB_2) Case $BR_5 Listbox_DeleteSelectedItems($LB_2) Case $BR_6 ;Populate GUICtrlSetData($LB_2, "") ; Clears the listbox For $x = 0 To 50 GUICtrlSetData($LB_2, $x & " Test", 0) Next EndSwitch WEnd ;note $hLB_ID - is the Listbox id Func Listbox_DeleteSelectedItems($hLB_ID) Local $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Get selected items Local $i, $slb = 0, $y, $x If $aSel[0] = 0 Then ;If the array is empty, there is no selection, or it is a single selection listbox For $x = 0 To _GUICtrlListBox_GetCount($hLB_ID) - 1 $y = _GUICtrlListBox_GetSel($hLB_ID, $x) If $y = True Then $slb = 1 _GUICtrlListBox_DeleteString($hLB_ID, $x) ;Perform a delete on single sel. LB ExitLoop EndIf Next EndIf If $slb = 0 Then _GUICtrlListBox_BeginUpdate($hLB_ID) For $i = $aSel[0] To 1 Step -1 ;Loop backwards and delete the selected items _GUICtrlListBox_DeleteString($hLB_ID, $aSel[$i]) Next _GUICtrlListBox_EndUpdate($hLB_ID) EndIf EndFunc ;==>Listbox_DeleteSelectedItems Func Listbox_ClearSelection($hLB_ID) ;Removes the selection from multi and single selection ListBox Local $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Code from Melba23 - Autoit Forum Local $slb, $x, $y If $aSel[0] = 0 Then _GUICtrlListBox_SetCurSel($hLB_ID, -1) $slb = 1 EndIf If $slb = 0 Then _GUICtrlListBox_BeginUpdate($hLB_ID) For $i = 1 To $aSel[0] _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i], False) Next _GUICtrlListBox_EndUpdate($hLB_ID) EndIf EndFunc ;==>Listbox_ClearSelection Func Listbox_ReverseSelection($hLB_ID) ;Logically, this function works only on multi-selection listboxes Local $i Local $aCou = _GUICtrlListBox_GetCount($hLB_ID) Local $cSel = _GUICtrlListBox_GetCaretIndex($hLB_ID) ;Save the caret _GUICtrlListBox_BeginUpdate($hLB_ID) For $i = 0 To $aCou _GUICtrlListBox_SetSel($hLB_ID, $i, Not (_GUICtrlListBox_GetSel($hLB_ID, $i))) Next _GUICtrlListBox_SetCaretIndex($hLB_ID, $cSel) ;Restore the caret _GUICtrlListBox_EndUpdate($hLB_ID) EndFunc ;==>Listbox_ReverseSelection Func Listbox_ItemMoveUD($hLB_ID, $iDir = -1) ;Listbox_ItemMoveUD - Up/Down Move Multi/Single item in a ListBox ;$iDir: -1 up, 1 down ;Return values -1 nothing to do, 0 nothing moved, >0 performed moves Local $iCur, $iNxt, $aCou, $aSel, $i, $m = 0, $y, $slb = 0 ;Current, next, Count, Selection, loop , movecount $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Put selected items in an array $aCou = _GUICtrlListBox_GetCount($hLB_ID) ;Get total item count of the listbox If $aSel[0] = 0 Then $y = _GUICtrlListBox_GetCurSel($hLB_ID) If $y > -1 Then _ArrayAdd($aSel, $y) $aSel[0] = 1 $slb = 1 EndIf EndIf ;WinSetTitle($hGUI, "", $aSel[0]) ;Debugging info Select Case $iDir = -1 ;Move Up For $i = 1 To $aSel[0] If $aSel[$i] > 0 Then $iNxt = _GUICtrlListBox_GetText($hLB_ID, $aSel[$i] - 1) ;Save the selection index - 1 text _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i] - 1, _GUICtrlListBox_GetText($hLB_ID, $aSel[$i])) ;Replace the index-1 text with the index text _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i], $iNxt) ;Replace the selection with the saved var $m = $m + 1 EndIf Next For $i = 1 To $aSel[0] ;Restore the selections after moving If $aSel[$i] > 0 Then If $slb = 0 Then _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i] - 1, 1) Else _GUICtrlListBox_SetCurSel($hLB_ID, $aSel[$i] - 1) EndIf EndIf Next Return $m Case $iDir = 1 ;Move Down If $aSel[0] > 0 Then For $i = $aSel[0] To 1 Step -1 If $aSel[$i] < $aCou - 1 Then $iNxt = _GUICtrlListBox_GetText($hLB_ID, $aSel[$i] + 1) _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i] + 1, _GUICtrlListBox_GetText($hLB_ID, $aSel[$i])) _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i], $iNxt) $m = $m + 1 EndIf Next EndIf For $i = $aSel[0] To 1 Step -1 ;Restore the selections after moving If $aSel[$i] < $aCou - 1 Then If $slb = 0 Then _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i] + 1, 1) Else _GUICtrlListBox_SetCurSel($hLB_ID, $aSel[$i] + 1) EndIf EndIf Next Return $m EndSelect Return -1 EndFunc ;==>Listbox_ItemMoveUD  
    • By topgundcp
      Hi, 
      This is my very first post in this forum and am also new with Autoit programming so be easy on me.
      Below is the code that I am trying to get the index of the item selected. No problem getting the text.
      Case $listEdition   ; handle of the list             local $index=0             $item=GUICTRLRead($listEdition)    ; This will return the text in the list             ; ==============   The loop below always fails  ==================             ; Meaning _GUICtrlListView_GetItemSelected($listEdition, $i) always return FALSE. WHY ???????              For $i = 0 To $editionArray[0] - 1   ; The content of the list in an array where editionArray[0] contains total count of items                 If _GUICtrlListView_GetItemSelected($listEdition, $i) Then                     $index = $i                     exitloop                 EndIf              Next              ;===================================================             ConsoleWrite( "Select Edition:     " & $item & "  index: " & $index & @CR) ....... Please look at the comments in the code & the pix attached.
      _GUICtrlListView_GetItemSelected($listEdition, $i) always returns FALSE.
      Another problem is on the list. It also populate  the total count of items from the Array. How can I skip this item from populating to the list ?.
      Please advise and thanks

    • By kneze
      Hi
      first step i write ipconfig output to ipconfig.txt. Now i try to find all Adapters and get for each adapter: Adapter Name, Description, Media State and Mac Adress and put it to listbox. I search for "Ethernet Adapter" but they are other entrys like Wireless Adapter .. How can i get all Adapters from ipconfig.txt and information for each adapter Adapter Name, Description, Media State and Mac Adress and write to listbox ? 
      Would appreciate any help!
      #include <File.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 451, 328, 856, 237) $Button1 = GUICtrlCreateButton("Button1", 8, 8, 75, 25) $List1 = GUICtrlCreateList("", 88, 8, 353, 305) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select ;Case $GUI_EVENT_CLOSE Case $msg = $GUI_EVENT_CLOSE Exitloop Case $msg = $Button1 $FilePath= "C:\temp\IPconfig.txt" $StringToSearch= "Ethernet adapter" $CaseSense=0 $Lines=_FileCountLines($FilePath) $hFile=FileOpen($FilePath,0) $Lines=_FileCountLines($FilePath) For $i=0 To Number($Lines) $Test=FileReadLine($hFile,$i) If StringInStr($Test,$StringToSearch,$CaseSense) Then $filereadAdapter = FileReadLine($hFile,$i) $filereadDescription = FileReadLine($hFile,$i+4) $filereadMediaState = FileReadLine($hFile,$i+2) $filereadMAcAdress = FileReadLine($hFile,$i+5) GUICtrlSetData($List1 , "Adapter: " & $filereadAdapter & @CRLF& "Description: "& $filereadDescription & @CRLF & "Media State: " & $filereadMediaState & @CRLF & "Mac Adress: " & $filereadMAcAdress& @CRLF) ;ExitLoop EndIf Next FileClose($hFile)  
       
    • By nacerbaaziz
      can we  create a list box with  Columns?
      welcome everybody
      Dears I have a question if you let me
      can we  create a list box with  Columns?
      i know we can create a list view with Columns
      but my question is about the list box
      I'm waiting your responses
      Thank you in advance
×
×
  • Create New...