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

Data from array not being inserted in command.

$
0
0

I am having a problem getting the data (printer names) from my array to show up in the RunWait command.  The data is read from an .ini file and used to create check-boxes.  In a later function (_PrinterInstall) it should be read again and used in the RunWait command to install the network printer.  When the command runs, the place where the printer name would be is blank.

AutoIt         
  1. #include <GUIConstantsEx.au3>
  2. Opt("GuiOnEventMode",1)
  3.  
  4. Global $CompanyName = IniRead("settings.ini","CompanyName","name","")
  5. Global $GUIheight = IniRead("settings.ini","WindowSize","height","400")
  6. Global $GUIwidth = IniRead("settings.ini","WindowSize","width","500")
  7. Global $printserver = IniRead("settings.ini","ServerSettings", "PrintServer", "Not Found")
  8.  
  9. Global $Printers = IniRead("settings.ini","Printers","PrinterList","NotFound")
  10. Global $printarr = StringSplit ($Printers, ",")
  11. Global $iPrinternumber = UBound($printarr) - 1
  12. Global $box[$printarr[0] + 1]
  13. Global $hService
  14.  
  15. Global $iTop = 0, $iLeft =(.1 * $GUIwidth)
  16.  
  17. GUICreate($CompanyName & " Printer Installer", $GUIwidth, $GUIheight)
  18. ;GUISetBkColor(0x33ccff)
  19.  
  20.  
  21. GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked")
  22.  
  23. $Title = GUICtrlCreateLabel("Select the Printers to be Installed", (.3 * $GUIwidth), 15, 300)
  24. GUICtrlSetFont($Title, 11,400,2)
  25.  
  26. For $i = 1 To $iPrinternumber
  27.      
  28.      If $iTop >= ($GUIheight - 100) Then
  29.        
  30.         $iLeft = (.6 * $GUIwidth)
  31.         $iTop = 0
  32.      Else
  33.      EndIf
  34.  
  35.  
  36.    $box[$i]= GUICtrlCreateCheckbox($printarr[$i], $iLeft, $iTop + 40)
  37.      
  38.      $iTop = $iTop + 20
  39.   Next
  40.  
  41. $InstallButton = GUICtrlCreateButton("Install Selected", .1 * $GUIwidth, $GUIheight - 50, 150)
  42. $ExitButton = GUICtrlCreateButton("Exit", .6 * $GUIwidth, $GUIheight -50, 150)
  43.  
  44. GUIctrlSetOnEvent($InstallButton, "_PrinterInstall")
  45. GUICtrlSetOnEvent($ExitButton, "_CLOSEClicked")
  46.  
  47.  
  48.  
  49.    Sleep(1000)
  50.  
  51. Func _CLOSEClicked ()
  52.    Exit
  53.  
  54. Func _PrinterInstall ()
  55.    
  56. SplashTextOn("", "Installing printer, please wait...", 150, 75)  
  57.  
  58.  
  59. For $i = 1 To $iPrinternumber
  60.  
  61.    If GUICtrlRead($box[$i]) = $GUI_CHECKED Then
  62.          
  63.       RunWait(@SystemDir & "\RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /q /u /n\\" & $printserver & "\" & $printarr[$i])
  64.      
  65.       GUICtrlSetState($box[$i], $GUI_UNCHECKED)
  66.    Else
  67.      
  68.    EndIf
  69.    
  70.      
  71.   next
  72.  
  73.  
  74.   MsgBox(0,"Done","Printer instlation complete")
  75.  

The contents of the .ini file I am using

 

[Printers]
PrinterList = PRT_BC_Counter_53, PRT_GL_Counter_49, PRT_GR_AcctsPayable_30, PRT_GR_APCheck, PRT_GR_Credit_31, PRT_GR_Exec_40, PRT_GR_Fireplaces, PRT_GR_HVACBuyers_62, PRT_GR_KitchensColor_61, PRT_GR_KitchensHP_54, PRT_GR_Outlet, PRT_GR_PartsCounter_24, PRT_GR_Ship_4, PRT_GR_ShippingOffice_39, PRT_GR_VaultColor_25, PRT_HL_Counter_50, PRT_HW_Counter_81, PRT_HW_Motors_64, PRT_HW_Shipping_63, PRT_KW_BackOffice_37, PRT_KW_Color_36, PRT_KZ_Counter_57, PRT_LN_COUNTER_79, PRT_Ls_Counter_56, PRT_MC_Counter_51, PRT_MU_Counter_87, PRT_MW_Counter_12, PRT_PL_Counter_59, PRT_PT_Counter_82, PRT_PT_HPG, PRT_SB_Counter_86, PRT_SF_Counter_83, PRT_TR_Counter_85, PRT_TY_Counter_84
 
 
[ServerSettings]
PrintServer = ad1
 
 
[WindowSize]
height = 400
width = 500
 
[CompanyName]
name = WMSDIST

Viewing all articles
Browse latest Browse all 12506

Trending Articles



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