Roger Posted November 21, 2004 Share Posted November 21, 2004 I have a problem trying to exit a script using GUI_EVENT_Close. When you select an item from the list it enables the second combo box on the window. After that, any attempt to close the script other than right clicking on the AutoIT tray icon fails. Here is the script. Example script and ini file below: expandcollapse popup#include <GUIConstants.au3> $path = @SCRIPTDIR & "\settings.ini" $printeritems = "Accounting" $CountLocation = 1 $CountPrinter = 1 GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered $location = GUICtrlCreateCombo ("", 10,10); create first item GUICtrlSetData(-1, ReadLocationINI(),""); add other item snd set a new default $printer = GUICtrlCreateCombo ("", 10,40); create first item GuiCtrlSetState (-1, $GUI_Disable) GuiSetState () Func ReadLocationINI() $record = IniRead ($path, "Settings", "Records", "") $locationitems = IniRead ($path, $CountLocation, "Location", "") If $record <> $CountLocation Then Do $CountLocation = $CountLocation + 1 $locationitems = $locationitems & "|" & IniRead ($path, $CountLocation, "Location", "") Until $record = $CountLocation EndIf Return $locationitems EndFunc Func ReadPrinterLocation() $record = IniRead ($path, $location, "Printers", "") $printeritems = IniRead ($path, $location, "Printer" & $CountPrinter, "") If $record <> $CountPrinter Then Do $CountPrinter = $CountPrinter + 1 $printeritems = $printeritems & "|" & IniRead ($path, $CountPrinter, "Location", "") Until $record = $CountPrinter EndIf Return $printeritems EndFunc Func LoadPrinters() $location = GuiRead ($location) GuiCtrlSetData ($printer, ReadPrinterLocation(), "") GuiCtrlSetState ($printer, $GUI_Enable) EndFunc ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $location Then LoadPrinters() EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend INI File Example: settings.ini (Must be in same directory as script.) [settings] Records=2 [1] Location=Accounting [Accounting] printers=1 printer1=printer93 printerdescription1=HP LaserJet 4000 [2] Location=Sales [sales] printers=3 printer1=printer91-1 printerdescription1=HP LaserJet 6MP next to Jim Barth printer2=printer90 printerdescription2=HP LaserJet 6MP in Front Lobby printer3=printer95 printerdescription3=HP LaserJet 4500TN Link to comment Share on other sites More sharing options...
this-is-me Posted November 21, 2004 Share Posted November 21, 2004 You shouldn't do it that way.. $location = GuiRead ($location) Try and see what you did above. Who else would I be? Link to comment Share on other sites More sharing options...
Roger Posted November 21, 2004 Author Share Posted November 21, 2004 Thanks this-is-me!! I wasn't paying attention to that little detail. :"> The corrected code is below: expandcollapse popup#include <GUIConstants.au3> $path = @SCRIPTDIR & "\settings.ini" $printeritems = "Accounting" $CountLocation = 1 $CountPrinter = 1 Global $locationprinter GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered $location = GUICtrlCreateCombo ("", 10,10); create first item GUICtrlSetData(-1, ReadLocationINI(),""); add other item snd set a new default $printer = GUICtrlCreateCombo ("", 10,40); create first item GuiCtrlSetState (-1, $GUI_Disable) GuiSetState () Func ReadLocationINI() $record = IniRead ($path, "Settings", "Records", "") $locationitems = IniRead ($path, $CountLocation, "Location", "") If $record <> $CountLocation Then Do $CountLocation = $CountLocation + 1 $locationitems = $locationitems & "|" & IniRead ($path, $CountLocation, "Location", "") Until $record = $CountLocation EndIf Return $locationitems EndFunc Func ReadPrinterLocation() $record = IniRead ($path, $locationprinter, "Printers", "") $printeritems = IniRead ($path, $locationprinter, "Printer" & $CountPrinter, "") If $record <> $CountPrinter Then Do $CountPrinter = $CountPrinter + 1 $printeritems = $printeritems & "|" & IniRead ($path, $locationprinter, "Printer" & $CountPrinter, "") Until $record = $CountPrinter EndIf Return $printeritems EndFunc Func LoadPrinters() $locationprinter = GuiRead ($location) GuiCtrlSetData ($printer, ReadPrinterLocation(), "") GuiCtrlSetState ($printer, $GUI_Enable) EndFunc ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $location Then LoadPrinters() EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now