Jump to content

Get Combo List from ini file


Recommended Posts

Hey, I'm pretty new to this autoit stuff, andf I apologize if this has been answered before, but I searched and couldn't find anything specifially on it. I am writing a script to remotely install a printer to a batch of computers. We have several drivers stored on a server and I want to make the combobox list the printers based on an ini file that is also stored on that server.

here is a short bit of the ini file (we'll call it printers.ini):

[Lexmark T640]

Model="Lexmark T640"

DriverName="Lexmark T640"

DriverINF="LMAAT2DA.INF"

DriverPack="lxt640.7z"

[Lexmark T642]

Model="Lexmark T642"

DriverName="Lexmark T642"

DriverINF="LMAAT2DA.INF"

DriverPack="lxt640.7z"

[Lexmark T630]

Model="Lexmark T630"

DriverName="Lexmark T630"

DriverINF="LMAAG2DA.INF"

DriverPack="lxt630.7z"

[Lexmark T632]

Model="Lexmark T632"

DriverName="Lexmark T632"

DriverINF="LMAAG2DA.INF"

DriverPack="lxt630.7z"

This is what I had before for the combo, but I want to pull it from an ini so I don't have to update the script every time we add another printer (and driver) to the server.

CODE
$PrinterList = GUICtrlCreateCombo("Choose Printer", 10, 58, 145, 25)

GUICtrlSetData(-1, "Brother 5250dn|HP 1300n|Lexmark E352dn|Lexmark T630|Lexmark T632|Lexmark T640|Lexmark T642")

Can anyone get me down the right path here? Thanks in advance,

Link to comment
Share on other sites

You could try something like this

#include <GUIConstants.au3>

Local $combo
$file = "printers.ini"
$printers = IniReadSectionNames($file)
For $i = 1 to $printers[0]
    $combo = $printers[$i] & "|" & $combo
Next

GUICreate("Test", 300, 50)
GUICtrlCreateCombo("", 10, 10, 100)
GUICtrlSetData(-1, $combo)
GUISetState()

While 1
$msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd
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...