Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Dynamic Checkboxes

$
0
0

I am attempting to write script with a gui to install network printers.  I have it set up to read the printer names from an .ini file and to create check boxes for each printer.  I can't seem to figure out how to see what boxes are checked and do something with the printer name next to the checked box.  Clicking the button does pop up a message box so I know it goes to the function, but my IF statement is completely skipped and I'm not sure how to make this work.  All help is greatly appreciated.  

 

 

Current Script

AutoIt         
  1. #include <GUIConstantsEx.au3>
  2. Opt("GuiOnEventMode",1)
  3. Opt("GUICoordMode",0)
  4.  
  5. Global $Printers = IniRead("settings.ini","Printers","PrinterList","NotFound")
  6. Global $printarr = StringSplit ($Printers, ",")
  7. Global $iPrinternumber = UBound($printarr) - 1
  8. Global $box[$printarr[0] + 1]
  9.  
  10.  
  11.  
  12. GUICreate("Printer Installer", 400, 400)
  13. GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked")
  14.  
  15. For $i = 1 To $iPrinternumber
  16.      
  17.    $box[$i]= GUICtrlCreateCheckbox($printarr[$i],-1, 20)
  18.      
  19.  
  20. $InstallButton = GUICtrlCreateButton("Install Selected", 160, 30)
  21. GUIctrlSetOnEvent($InstallButton, "_PrinterInstall")
  22.  
  23.  
  24.  
  25.  
  26.    Sleep(1000)
  27.  
  28. Func _CLOSEClicked ()
  29.    Exit
  30.  
  31. Func _PrinterInstall ()
  32.  
  33. For $i = 1 To $iPrinternumber
  34.  
  35.    If GUICtrlGetState($box[$i]) = $GUI_CHECKED Then
  36.      
  37.       MsgBox(0,$box[$i],$box[$i] & " has been selected.")
  38.      
  39.    Else
  40.      
  41.      
  42.    EndIf
  43.    
  44.      
  45.  MsgBox(0,"Test", "Button has been clicked")
  46.  

The .ini file contents

 

[Printers]
PrinterList = Printer 1, Printer 2, Printer3, Printer 4, New_Test_printer

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>