Jump to content

GUI Array to ComboBox problem


 Share

Recommended Posts

Please help. I am still kind of a noob at making gui's and using array's and I have a weird problem. I have a GUI that i am making to create a printer install process which uses a _FileListToArray to fill combo boxes so that when the IT person doing the printer install can select the make and model of the printer and the script will copy the proper drivers from our internal server where we store drivers for several printer models to the computer that will have the printer installed. However my GUI will display the models available for all the makes except for 1 (Canon). I found that at first it wasn't working in my code because originally I spelled "Canon" wrong. I had "Cannon" (2 n's) and the folder on our sever has only one "n". I fixed that but it still will not display the model folders when I select the canon folder. Since this is our company network if your run the script it won't display any folders for anyone providing assistance. but here is the code with some private info edited to protect company assets. it was working for several days and then just stopped. I tested on other computers that I have autoit on and it works on them but not the one I do all the coding on. my machine is a win7 enterprise 64bit. it works also on win7 enterprise 32bit and 64bit (other computers) as well as winxp 32bit. Can someone provide me some insight as to why this is not working on my machine any more. its just the canon option all the others (HP, Brother, ect.) work.

#include <File.au3>
#include <Array.au3>
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$PrinterDirectory = ("\\"servername"\app_inst$\PRINTER DRIVERS")
;$ModelDirectory
Dim $Flag = 0
$PrinterSelect = GUICreate("Printer Selection", 625, 443, 192, 124, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
$PrinterMake = GUICtrlCreateCombo("Printer Make", 120, 96, 145, 25, BitOR($CBS_DROPDOWN, $WS_VSCROLL))
$PrinterModel = GUICtrlCreateCombo("", 352, 96, 145, 25, BitOR($CBS_DROPDOWN, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("OK", 440, 384, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Cancel", 536, 384, 75, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Please Select Printer Make", 120, 72, 148, 17, $SS_CENTER)
$Label2 = GUICtrlCreateLabel("Please Select Printer Model", 352, 72, 134, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$PrinterArray = _FileListToArray($PrinterDirectory)
;_ArraySort($PrinterArray)
For $i = 1 To UBound($PrinterArray) - 1
    GUICtrlSetData($PrinterMake, $PrinterArray[$i])
Next

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
        Case _GUICtrlComboBox_GetEditText($PrinterMake) = "HP"
            GUICtrlSetData(4, "")
            $ModelArray = _FileListToArray("\\"servername"\app_inst$\PRINTER DRIVERS\HP")
            _ArraySort($ModelArray)
            For $i = 1 To UBound($ModelArray) - 1
                GUICtrlSetData($PrinterModel, $ModelArray[$i])
            Next
            _GUICtrlComboBox_SetEditText($PrinterMake, "HP\")

        Case _GUICtrlComboBox_GetEditText($PrinterMake) = "CANON"
            GUICtrlSetData(4, "")
            $ModelArray = _FileListToArray("\\"servername"\app_inst$\PRINTER DRIVERS\CANON")
            _ArraySort($ModelArray)
            For $i = 1 To UBound($ModelArray) - 1
                GUICtrlSetData($PrinterModel, $ModelArray[$i])
            Next
            _GUICtrlComboBox_SetEditText($PrinterMake, "CANON\")

        Case _GUICtrlComboBox_GetEditText($PrinterMake) = "OCE"
            ;GUICtrlSetData(4, "")
            $ModelArray = _FileListToArray("\\"servername"\app_inst$\PRINTER DRIVERS\OCE")
            _ArraySort($ModelArray)
            For $i = 1 To UBound($ModelArray) - 1
                GUICtrlSetData($PrinterModel, $ModelArray[$i])
            Next
            _GUICtrlComboBox_SetEditText($PrinterMake, "OCE\")

        Case _GUICtrlComboBox_GetEditText($PrinterMake) = "LEXMARK"
            GUICtrlSetData(4, "")
            $ModelArray = _FileListToArray("\\"servername"\app_inst$\PRINTER DRIVERS\LEXMARK")
            _ArraySort($ModelArray)
            For $i = 1 To UBound($ModelArray) - 1
                GUICtrlSetData($PrinterModel, $ModelArray[$i])
            Next
            _GUICtrlComboBox_SetEditText($PrinterMake, "LEXMARK\")

        Case _GUICtrlComboBox_GetEditText($PrinterMake) = "BROTHER"
            GUICtrlSetData(4, "")
            $ModelArray = _FileListToArray("\\"servername"\app_inst$\PRINTER DRIVERS\BROTHER")
            _ArraySort($ModelArray)
            For $i = 1 To UBound($ModelArray) - 1
                GUICtrlSetData($PrinterModel, $ModelArray[$i])
            Next
            _GUICtrlComboBox_SetEditText($PrinterMake, "BROTHER\")

        Case _GUICtrlComboBox_GetEditText($PrinterMake) = "Xerox Phaser 550"
            GUICtrlSetData(4, "")
            $ModelArray = _FileListToArray("\\"servername"\app_inst$\PRINTER DRIVERS\Xerox Phaser 550")
            _ArraySort($ModelArray)
            For $i = 1 To UBound($ModelArray) - 1
                GUICtrlSetData($PrinterModel, $ModelArray[$i])
            Next
            _GUICtrlComboBox_SetEditText($PrinterMake, "Xerox Phaser 550\")
        Case $nMsg = $Button1
            $Make = GUICtrlRead(3)
            $Model = GUICtrlRead(4)
            $DriverDirectory = ("\\"servername"\app_inst$\PRINTER DRIVERS\" & $Make & $Model)
            MsgBox(1, "", $DriverDirectory)
            ;MsgBox(1, "", @CommonFilesDir )
            DirCopy($DriverDirectory, "C:\Printer Drivers\" & $Make & $Model)
        Case $nMsg = $Button2 ; Close Button EVENT
            GUIDelete()
            Exit
        Case $nMsg = $GUI_EVENT_CLOSE ; Close Window EVENT
            GUIDelete()
            Exit
    EndSelect
WEnd
Link to comment
Share on other sites

How does any of it work with the bad syntax strings you have for file paths in the _FileListToArray() calls? For example:

;  $PrinterDirectory = ("\\"servername"\app_inst$\PRINTER DRIVERS")

$PrinterDirectory = ("\\" & $servername & "\app_inst$\PRINTER DRIVERS")

...except you didn't define $servername anywhere, so what did you mean that to be?

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

How does any of it work with the bad syntax strings you have for file paths in the _FileListToArray() calls? For example:

;  $PrinterDirectory = ("\\"servername"\app_inst$\PRINTER DRIVERS")

$PrinterDirectory = ("\\" & $servername & "\app_inst$\PRINTER DRIVERS")

...except you didn't define $servername anywhere, so what did you mean that to be?

:unsure:

I am sorry I thought I explained that.. I took out the server name because it is a company server I was paranoid about giving out sensitive info. I replaced the actual server name with "servername" in the script. The script wouldn't work for anyone not on our network anyway so I just replaced the name with a generic term "servename". I was really just hoping for someone to spot an error in my coding and although that is what you have done (Thank you) it is not the cause of my problem. I assure you the script works as expected on any computer on our network including on my computer except that, on mine it does not populate the _filelisttoarray for the combobox when I select the canon folder. I am sorry I don't know of a way to provide a working copy of the gui with out being on our internal network. Thanks for your help I hope you have an idea of what my problem could be. Edited by jimillett
Link to comment
Share on other sites

OK, so you just meant it this way:

$PrinterDirectory = "\\servername\app_inst$\PRINTER DRIVERS"
Every sane person sanitizes their posts, just try to post valid syntax while you're doing it.

Add an _ArrayDisplay() right after _FileListToArray() plus some error checking:

Case _GUICtrlComboBox_GetEditText($PrinterMake) = "CANON"
        GUICtrlSetData(4, "")
        $ModelArray = _FileListToArray("\\servername\app_inst$\PRINTER DRIVERS\CANON")
        $iErrSav = @error
        If IsArray($ModelArray) Then
            _ArrayDisplay($ModelArray, "Debug: $ModelArray")
        Else
            MsgBox(16, "Error", "_FileListToArray() failed; @error = " & $iErrSav)
        EndIf

        ; ...

That should give you some data to go on.

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...