Jump to content

ListView \ Multi CheckBoxes \ Run multi cmds - Uncheck Checked Items

Recommended Posts

So I'm teaching myself through the forum and help files - Listview and Checkboxes and the commands that control them.  My project has two tabs - each with a listview on them - One is filed with .exe files from a directory and the other is filed with computer info from a .csv file.

No problems there.

I am able to setup both left and right click optionsmenus.

I am able to check uncheck individual checkboxex - checkuncheck all items.

My issue is I am attempting to Click a (Run) button and execute a command on only the checked items - once the command is run I want the checked item box to become unchecked.  I can get it to work either by running a single checked item or [Odd] a group of checked items in a series.   example item 0, 1,2,3,4, and so on.  Yet when checking say items 1,3, 5 only the first check box is unchecked and the others are left.  The command still runs but the items are still checked.

Here is where I believe this should be happening  -

Below you can see I'm throwing out WOL commands throught NetScan   (Condensed version - I have other commands under the WOL option)

1. First Get the count of the listview Items

2. Get only Items that are checked

3. put into array

4. run through Ping check - and run command.

Running the command on only the checked items work great yet I can't get the checked Items to uncheck after the command has run on a non series group of checked items.  

I've put _GUICtrlListView_SetItemChecked and attempted other options found in the forum - all over the place to see what I get but if its not in a series - 1,2,3,4. uncheck fails on all but those in a series.   (Odd)


I hope this makes some meaning ....

Func _RunSelectedOption()
    Local $aSelected[1], $1, $2, $iItemCount, $sFileName
    $iItemCount = _GUICtrlListView_GetItemCount($cListView);--- Number of items in listview
    $2 = 0
    For $1 = 1 To $iItemCount
        If _GUICtrlListView_GetItemChecked($cListView, $1 - 1) = True Then ;-- which chkbox's are checked
            $aSelected[$2] = _GUICtrlListView_GetItemTextArray($cListView, $1 - 1);-- Take listview items\sub-items [column 1,2,3]
           ReDim $aSelected[UBound($aSelected) + 1]
           $2 += 1
    For $1 = 1 To UBound($aSelected) -1
        $sFileName = $aSelected[$1 - 1]
;-----------------------------------------------------------Wake Onlan
            If GUICtrlRead($hChkbxMWol) = $GUI_CHECKED Then
                Local $Replaced = StringReplace($sFileName [3],"-","")
                Run($NetScan & " /wol:" & $Replaced, "",@SW_HIDE)
                    if GUICtrlRead ($hCheckbox) = $GUI_CHECKED Then
                        MsgBox(64,"WOL", "Packet Sent To - " & $sFileName [1] & " \ " & $sFileName [3],3)
            EndIf           Else
                MsgBox(48,"Connection", $sFileName [1] & " - Not Found Online", 3);-- Failed Ping Msg...

My next step with the project is to be able to ping the checked items then in the listview indicate online or Offline - or something to that effect.

Learning alot...

Hey much Thanks in advance....

I Break and Fix things... If the surf is up I'm outta here.....

Link to post
Share on other sites

Note to add - Sorry the example does not show my ping action because it only happens on the other options not on the WOL option.  Again I did not place those options above because I didn't think it is where the issue is.   I'm missing something in the process....


I Break and Fix things... If the surf is up I'm outta here.....

Link to post
Share on other sites

You may want to assign each checkbox an array variable:

$Preferences[1]               = GUICtrlCreateCheckbox("Future Use 6", 320, 329, 97, 17)
$Preferences[2]               = GUICtrlCreateCheckbox("Future Use 6", 320, 329, 97, 17)
$Preferences[3]               = GUICtrlCreateCheckbox("Future Use 6", 320, 329, 97, 17)

and when you go to see whats clicked...

Dim $Preferences[50]

for $i = 1 to 50

      If _IsChecked($Preferences[$i]) Then
                    MsgBox($MB_SYSTEMMODAL, "", "The checkbox is checked.")
                    MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.")

as a rough example.

C0d3 is P0etry( ͡° ͜ʖ ͡°)

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 have an ListView with checkboxes and about 300 - 400 items. Entire list is loaded (from ini) every time and I need to store and load "checked scenario" by name. 
      Store list of checked indexless is a bad idea because in the case of sorting the list - scenario will no longer be correct.
      What is the best way to store list of various scenarios of checked items?
      Base code and database ini are attached 
      Example_LV_Store_Scenario.au3 Example.ini
  • Create New...