Iznogoud Posted March 19, 2006 Share Posted March 19, 2006 (edited) I am still working on a script and i have a question about a part of it. I have a combo box: $klantnaam=GuiCtrlCreatecombo("<klantnaam>",$kantlijn+100, 240, 250, 20) While 1 $Kline = FileReadLine($klantfile) If @error = -1 Then ExitLoop $Klanten = $Klanten & "|" & $Kline WEnd GUICtrlSetData(-1, $Klanten) klant is a dutch word for customer Also i got an input box: $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam", " bijv.: Company (City) ", "", 300, 125) Is it possible to put the information from $nieuweklant into the Combobox? I have created a work around like this: Case $msg = $nieuweklantbutton $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam", " bijv.: Company (City) ", "", 300, 125) $klantfile = FileOpen("C:\company\Klanten.txt", 1) FileWriteLine($klantfile, $nieuweklant) ; SETTING NEW INFORMATION FROM NEW CUSTOMER GUICtrlSetState($klantnaam, $GUI_HIDE) $labelklantnaam=GUICtrlCreateLabel ($nieuweklant, $kantlijn+100 ,240 ,250 ,20) GUICtrlSetState($nieuweklantbutton, $GUI_DISABLE) $nieuweklanttoegevoegd = 1 But i don't think this is the best way to solve this and i would like to know the best solution. Because GUICtrlSetData doesn't work for some weird reason. If you guys need to see the whole script let me know. Edited March 20, 2006 by Iznogoud Link to comment Share on other sites More sharing options...
cppman Posted March 20, 2006 Share Posted March 20, 2006 I Think this is what ur talking about: here is a little example: #include <GuiConstants.au3> GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Input_1 = GuiCtrlCreateInput("Input1", 40, 50, 140, 20) $Button_2 = GuiCtrlCreateButton("Add", 190, 50, 130, 20) $Combo_3 = GuiCtrlCreateCombo("Combo3", 110, 150, 190, 21) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 GUICtrlSetData($Combo_3, GUICtrlRead($Input_1)) EndSelect WEnd Exit Miva OS Project Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 20, 2006 Share Posted March 20, 2006 I am still working on a script and i have a question about a part of it. I have a combo box: $klantnaam=GuiCtrlCreatecombo("<klantnaam>",$kantlijn+100, 240, 250, 20) While 1 $Kline = FileReadLine($klantfile) If @error = -1 Then ExitLoop $Klanten = $Klanten & "|" & $Kline WEnd GUICtrlSetData(-1, $Klanten) klant is a dutch word for customer Also i got an input box: $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam", " bijv.: Mareco Automatisering (Dedemsvaart) ", "", 300, 125) Is it possible to put the information from $nieuweklant into the Combobox? I have created a work around like this: Case $msg = $nieuweklantbutton $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam", " bijv.: Mareco Automatisering (Dedemsvaart) ", "", 300, 125) $klantfile = FileOpen("C:\Mareco\Klanten.txt", 1) FileWriteLine($klantfile, $nieuweklant) ; SETTING NEW INFORMATION FROM NEW CUSTOMER GUICtrlSetState($klantnaam, $GUI_HIDE) $labelklantnaam=GUICtrlCreateLabel ($nieuweklant, $kantlijn+100 ,240 ,250 ,20) GUICtrlSetState($nieuweklantbutton, $GUI_DISABLE) $nieuweklanttoegevoegd = 1 But i don't think this is the best way to solve this and i would like to know the best solution. Because GUICtrlSetData doesn't work for some weird reason. If you guys need to see the whole script let me know. I rewrote it as a working standalone example: ; Adding to a combo box from an input box #include <GuiConstants.au3> $GuiHandle = GUICreate("Combo/Input Box Test", 400, 100) $Label_1 = GUICtrlCreateLabel("Combo Box: ", 10, 10, 80, 30) $klantnaam = GUICtrlCreateCombo("<klantnaam>", 100, 10, 250, 30) $nieuweklantbutton = GUICtrlCreateButton("New Customer", 50, 50, 100, 40) $DoneButton = GUICtrlCreateButton("DONE", 250, 50, 100, 40) $Klanten = "Customer One|Customer Two|Customer Three" GUICtrlSetData($klantnaam, $Klanten) GUISetState(@SW_SHOW, $GuiHandle) While (1) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $nieuweklantbutton $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam") $Klanten = $Klanten & "|" & $nieuweklant ; Only write the new data, not all the choices, to the control GUICtrlSetData($klantnaam, $nieuweklant) Case $msg = $DoneButton ExitLoop EndSelect WEnd $Selection = GUICtrlRead($klantnaam) MsgBox(64, "Results", "Choices were: " & $Klanten & @CRLF & _ "Selection was: " & $Selection) Hope that helps... Note that GuiCtrlSetData will add an item to the combo box list, not overwrite the whole list. One thing I didn't know how to do was REMOVE one of the items from the list. But that could be done by deleting and recreating the combo box, if nothing else. Is there a better way to delete existing items from a combo box list? 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 More sharing options...
GaryFrost Posted March 20, 2006 Share Posted March 20, 2006 I rewrote it as a working standalone example: ; Adding to a combo box from an input box #include <GuiConstants.au3> $GuiHandle = GUICreate("Combo/Input Box Test", 400, 100) $Label_1 = GUICtrlCreateLabel("Combo Box: ", 10, 10, 80, 30) $klantnaam = GUICtrlCreateCombo("<klantnaam>", 100, 10, 250, 30) $nieuweklantbutton = GUICtrlCreateButton("New Customer", 50, 50, 100, 40) $DoneButton = GUICtrlCreateButton("DONE", 250, 50, 100, 40) $Klanten = "Customer One|Customer Two|Customer Three" GUICtrlSetData($klantnaam, $Klanten) GUISetState(@SW_SHOW, $GuiHandle) While (1) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $nieuweklantbutton $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam") $Klanten = $Klanten & "|" & $nieuweklant ; Only write the new data, not all the choices, to the control GUICtrlSetData($klantnaam, $nieuweklant) Case $msg = $DoneButton ExitLoop EndSelect WEnd $Selection = GUICtrlRead($klantnaam) MsgBox(64, "Results", "Choices were: " & $Klanten & @CRLF & _ "Selection was: " & $Selection) Hope that helps... Note that GuiCtrlSetData will add an item to the combo box list, not overwrite the whole list. One thing I didn't know how to do was REMOVE one of the items from the list. But that could be done by deleting and recreating the combo box, if nothing else. Is there a better way to delete existing items from a combo box list? _GUICtrlComboDeleteString SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Iznogoud Posted March 20, 2006 Author Share Posted March 20, 2006 I rewrote it as a working standalone example: ; Adding to a combo box from an input box #include <GuiConstants.au3> $GuiHandle = GUICreate("Combo/Input Box Test", 400, 100) $Label_1 = GUICtrlCreateLabel("Combo Box: ", 10, 10, 80, 30) $klantnaam = GUICtrlCreateCombo("<klantnaam>", 100, 10, 250, 30) $nieuweklantbutton = GUICtrlCreateButton("New Customer", 50, 50, 100, 40) $DoneButton = GUICtrlCreateButton("DONE", 250, 50, 100, 40) $Klanten = "Customer One|Customer Two|Customer Three" GUICtrlSetData($klantnaam, $Klanten) GUISetState(@SW_SHOW, $GuiHandle) While (1) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $nieuweklantbutton $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam") $Klanten = $Klanten & "|" & $nieuweklant ; Only write the new data, not all the choices, to the control GUICtrlSetData($klantnaam, $nieuweklant) Case $msg = $DoneButton ExitLoop EndSelect WEnd $Selection = GUICtrlRead($klantnaam) MsgBox(64, "Results", "Choices were: " & $Klanten & @CRLF & _ "Selection was: " & $Selection) Hope that helps... Note that GuiCtrlSetData will add an item to the combo box list, not overwrite the whole list. One thing I didn't know how to do was REMOVE one of the items from the list. But that could be done by deleting and recreating the combo box, if nothing else. Is there a better way to delete existing items from a combo box list? If i copy and paste your code and try to run it i got errors wich i cannot resolve because not enough knowledge YET But rebuilding the list wich you did with this code: $Klanten = $Klanten & "|" & $nieuweklant ; Only write the new data, not all the choices, to the control GUICtrlSetData($klantnaam, $nieuweklant) This is at least a good part wich i was looking for, but still i am trying to run your script because i would like to know what i am doing wrong. This is the error wich i get: ERROR: syntax error (illegal character) "Selection was: " & $Selection)# Link to comment Share on other sites More sharing options...
nfwu Posted March 20, 2006 Share Posted March 20, 2006 This is the error wich i get:ERROR: syntax error (illegal character) "Selection was: " & $Selection)#Delete that "#" at the end of the line!!!!#) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Iznogoud Posted March 20, 2006 Author Share Posted March 20, 2006 Delete that "#" at the end of the line!!!! #) Think i was sleeping If i add the code: $Klanten = $Klanten & "|" & $nieuweklant ; Only write the new data, not all the choices, to the control GUICtrlSetData($klantnaam, $nieuweklant) So if i add a new customer the name of the customer is automatically selected in the Combo box field. But sometimes it doesn't. Why is that? Is it a bug or am i forgetting something? I will post the full code so maybe something is wrong before expandcollapse popup#include <GuiConstants.au3> ; GUI Width x Hight GuiCreate("Netviewer", 499, 508) ; BACKGROUND GUISetBkColor (0xFFFFFF) ; VARIABLES $kantlijn = "70" $Datum = (@MDAY & "-" & @MON & "-" & @YEAR) $Gebruiktetijdinmin=0 $Klanten="" $Medewerkers="" $nieuweklanttoegevoegd="" ; CHECKING FILES $logfile = FileOpen("C:\company\Log.csv", 1) If $logfile = -1 Then MsgBox(0, "Error - (Log bestand)", "Kan het bestand niet openen.") Exit EndIf $klantfile = FileOpen("C:\company\Klanten.txt", 0) If $klantfile = -1 Then MsgBox(0, "Error - (Klanten bestand)", "Kan het bestand niet openen.") Exit EndIf $medewerkersfile = FileOpen("C:\company\Medewerkers.txt", 0) If $medewerkersfile = -1 Then MsgBox(0, "Error - (Medewerkers bestand)", "Kan het bestand niet openen.") Exit EndIf ; LOGO GUICtrlCreatePic("C:\company\logo1.jpg",0,0, 499,160) GUICtrlCreatePic("C:\company\logo2.jpg",0,420, 499,88) ; LABELS $labelmedewerker=GUICtrlCreateLabel ("Medewerker :",$kantlijn ,202 ,65 ,20) $labelklantnaam=GUICtrlCreateLabel ("Klantnaam :",$kantlijn ,242 ,65 ,20) $labelopmerking1=GUICtrlCreateLabel ("Opmerking 1 :",$kantlijn ,282 ,66 ,20) $labelopmerking2=GUICtrlCreateLabel ("Opmerking 2 :",$kantlijn ,322 ,66 ,20) ; COMBO BOX $medewerker=GuiCtrlCreatecombo("<medewerker>",$kantlijn+100 , 200, 250, 100) While 1 $Wline = FileReadLine($Medewerkersfile) If @error = -1 Then ExitLoop $Medewerkers = $Medewerkers & "|" & $Wline WEnd GUICtrlSetData(-1, $Medewerkers) $klantnaam=GuiCtrlCreatecombo("<klantnaam>",$kantlijn+100, 240, 250, 20) While 1 $Kline = FileReadLine($klantfile) If @error = -1 Then ExitLoop $Klanten = $Klanten & "|" & $Kline WEnd GUICtrlSetData(-1, $Klanten) ; INPUT FIELD $opmerking1=GuiCtrlCreateInput("<opmerking>",$kantlijn+100, 280, 250, 20) $opmerking2=GuiCtrlCreateInput("<opmerking>",$kantlijn+100, 320, 250, 20) ; START BUTTON $startbutton = GUICtrlCreateButton ("Start Netviewer",$kantlijn+125,380,150,20) $nieuweklantbutton = GUICtrlCreateButton ("Nieuw", $kantlijn+360,240,20,20,$BS_ICON) GUICtrlSetImage (-1, "shell32.dll",21, 0) ; GUI MESSAGE LOOP GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $nieuweklantbutton $nieuweklant = InputBox("Nieuwe klant toevoegen", "Klantnaam", " bijv.: Company (City) ", "", 300, 125) $klantfile = FileOpen("C:\company\Klanten.txt", 1) FileWriteLine($klantfile, $nieuweklant) $Klanten = $Klanten & "|" & $nieuweklant ; Only write the new data, not all the choices, to the control GUICtrlSetData($klantnaam, $nieuweklant) Case $msg = $GUI_EVENT_CLOSE FileClose($logfile) FileClose($klantfile) FileClose($medewerkersfile) Exit Case $msg = $startbutton ; START TIME $BegintijdUur=(@HOUR) $BegintijdMin=(@MIN) $Begintijd=($BegintijdUur & ":" & $BegintijdMin) ExitLoop EndSelect Wend ; DISABLE BUTTONS GUICtrlSetState($startbutton, $GUI_HIDE) GUICtrlSetState($nieuweklantbutton, $GUI_DISABLE) GUICtrlSetState($medewerker, $GUI_DISABLE) GUICtrlSetState($klantnaam, $GUI_DISABLE) GUICtrlSetState($opmerking1, $GUI_DISABLE) GUICtrlSetState($labelmedewerker, $GUI_DISABLE) GUICtrlSetState($labelklantnaam, $GUI_DISABLE) GUICtrlSetState($labelopmerking1, $GUI_DISABLE) ; START APPLICATION Run("notepad.exe") ProcessWaitClose("notepad.exe") ; END TIME $EindtijdUur=(@HOUR) $EindtijdMin=(@MIN) $Eindtijd=($EindtijdUur & ":" & $EindtijdMin) ; USED TIME $Gebruiktetijd=(($EindtijdUur-$BegintijdUur) & " uur en " & ($EindtijdMin-$BegintijdMin) & " minuten" ) ; USED TIME IN MINUTES $Gebruiktetijdinmin=(($EindtijdUur-$BegintijdUur)*60+($EindtijdMin-$BegintijdMin)) ; EXIT BUTTON $afsluiten = GUICtrlCreateButton ("Afsluiten",$kantlijn+125,380,150,20) ; GUI MESSAGE LOOP While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $afsluiten ExitLoop EndSelect Wend FileWriteLine($logfile, $Datum & ";" & $Begintijd & ";" & $Eindtijd & ";" & $Gebruiktetijdinmin & ";" & $Gebruiktetijd & ";" & GUICtrlRead($medewerker) & ";" & GUICtrlRead($klantnaam) & ";" & GUICtrlRead($opmerking1) & ";" & GUICtrlRead($opmerking2)) FileClose($logfile) FileClose($klantfile) FileClose($medewerkersfile) 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