Sign in to follow this  
Followers 0
FMS

When select combobox change input field

4 posts in this topic

#1 ·  Posted (edited)

Hello,

I've writing this code and I'm a little stuck in what i want to do.
When I select the combobox I want to get the ini information inside the multiline input field.

I know that what I'm doing now is wrong but maybe this helps to clearify things in what I want to do.

Does somebody knows how to do this , or can help me?
 

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <File.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <Date.au3>

check_file_exist()


$Form1 = GUICreate("Form1", 320, 260, 192, 324);(b,h,,),30
$Tab1 = GUICtrlCreateTab(5, 5, 310, 250) ;(,,b,h)
   $TabSheet3 = GUICtrlCreateTabItem("Edit")
      $Label_tab_select = GUICtrlCreateLabel("select", 40, 50, 80, 25)
      $tab_select = GUICtrlCreateCombo(" tab 1", 40, 70, 80, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
         GUICtrlSetData(-1, " tab 2")
      $Label_BtnSelect = GUICtrlCreateLabel("nr", 125, 50, 80, 25)
      $BtnSelect = GUICtrlCreateCombo(" 1", 125, 70, 60, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
         GUICtrlSetData(-1, " 2 ")
      $Label_BtnName = GUICtrlCreateLabel("name", 190, 50, 80, 25)
      $BtName = GUICtrlCreateInput("", 190, 70, 80, 21)
      $multiline = GuiCtrlCreateEdit("this text needs to be changed at selection of combobox",15, 105, 290, 110)
      ;the next line is to clearify things :)
      ;$multiline = GuiCtrlCreateEdit(IniRead($ini_location_buttons, "btn00" & GUICtrlRead($BtnSelect), "text"),15, 105, 290, 110)
      $Btn301 = GUICtrlCreateButton("Cancel", 40, 220, 75, 25)
      $Btn302 = GUICtrlCreateButton("Save", 152, 220, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Btn301
            Exit
         Case $Btn302
            Exit
    EndSwitch
 WEnd

Func check_file_exist()
   If FileExists(@SCRIPTDIR & "\ini.ini") Then
      Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini"
   Else
      If Not _FileCreate(@SCRIPTDIR & "\buttons.ini") Then
         MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting ini.      error:" & @error)
      Else
         Global $ini_location_buttons = @SCRIPTDIR & "\ini.ini"
         create_new_ini()
      EndIf
   EndIf
EndFunc

Func create_new_ini()
   $file = FileOpen($ini_location_buttons, 1)
      Local $i = 1
      local $j = 0
      Do
         if $i = 10 then $j = ""
         FileWrite($file, "[btn0" & $j & $i & "]"& @CRLF)
         FileWrite($file, "button_name=Button " & $i & @CRLF)
         FileWrite($file, "text=lorum ipsum" & $i & @CRLF)
         $i = $i + 1
      Until $i = 3
   FileClose($file)
EndFunc

 

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites



Here's a little script for demostrating Teamworking ComboBox and Ini-functions: Textbausteine.au3

This 2 func's doing the trick:

Func _writeTB($sId_TB) ;Routine zum Screiben in INI
    ;hier werdeb die Zeichen @CR (Wagebrücklauf) @LF Zeilenumbruche und @CRLF getauscht
    $write1 = GUICtrlRead($hedtBox)
    $write1 = StringReplace($write1, @CRLF, "_%CRLF%_")
    $write1 = StringReplace($write1, @CR, "_%CR%_")
    $write1 = StringReplace($write1, @LF, "_%LF%_")
    If $write1 <> "" Then IniWrite($sAppIni, "Bausteine", $sId_TB, $write1) ;wenn nicht leer in INI schreien
EndFunc   ;==>_writeTB

Func show_Selection() ;Selekzion anzeigen
    If GUICtrlRead($hcboTB) = $sElect Then ;es ist kein Textbaustein asgewählt
        GUICtrlSetState($hbtnClear, $GUI_DISABLE) ;Leeren-Button disablen
        GUICtrlSetData($hedtBox, "") ;also EDIT leeren
    Else
        GUICtrlSetState($hbtnClear, $GUI_ENABLE) ;Leeren-Button enablen
        $sId_TB = GUICtrlRead($hcboTB) ;Kurzbezeichnng holen
        ;ConsoleWrite("ausgewählt: " & $sId_TB & @CRLF)    ;Kontrolausgabe in Console
        $write1 = IniRead($sAppIni, "Bausteine", $sId_TB, "") ;Baustein aus INI lesen
        ;hier werdeb die Zeichen für @CR (Wagebrücklauf) @LF Zeilenumbruche und @CRLF zurück getauscht
        $write1 = StringReplace($write1, "_%CRLF%_", @CRLF) ;
        $write1 = StringReplace($write1, "_%CR%_", @CR)
        $write1 = StringReplace($write1, "_%LF%_", @LF)

        GUICtrlSetData($hedtBox, $write1) ;Baustein in Edit-Box anzeigen
    EndIf
EndFunc   ;==>show_Selection

by StringReplace 'ing the  bad chr's for Inifiles when writting and replacing back when reading.

Share this post


Link to post
Share on other sites

Thanks @AutoBert this looks indeed like what i needed :)
unfortunaly I'm a little bit new on autoit and mine deutsch is not that great.
Do you have a more simplefied version?
I do not know how to use theese functions inside mine script :(


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

For understanding the code must be enough for a progidy, german is not needed.

But for better understanding what i did in this 2 funcs, because IniRead terminates reading by first CR or  LF:

  • i just replaced @CRLF, @CR and @LF before writing (IniWrite)
  • After reading (IniRead) i replaced back to origin text 

and here a old example (just extended )of mine with combobox, IniRead and yet 1 multiline Editcontrol: miniDL2.au3

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • kstriyhon
      By kstriyhon
      hello Comunity i am new to autoit and i bump into a pitfall regarding the creation of objects in a dinamyc way but more especific  creating combobox at runtime
      i need many comboboxes and sofar i createdthem manually 
      like this 
      $idCombo_1 = GUICtrlCreateCombo("", 500, 40, 130, 21)     $idCombo_2 = GUICtrlCreateCombo("", 500, 70, 130, 21)     $idCombo_3 = GUICtrlCreateCombo("", 500, 100, 130, 21)     $idCombo_4 = GUICtrlCreateCombo("", 500, 130, 130, 21)     $idCombo_5 = GUICtrlCreateCombo("", 500, 160, 130, 21)     $idCombo_6 = GUICtrlCreateCombo("", 500, 190, 130, 21)     $idCombo_7 = GUICtrlCreateCombo("", 500, 220, 130, 21)     $idCombo_8 = GUICtrlCreateCombo("", 500, 250, 130, 21)     $idCombo_9 = GUICtrlCreateCombo("", 500, 280, 130, 21)     GUICtrlSetData($idCombo_1, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_2, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_3, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_4, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_5, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_6, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_7, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_8, "Item1|Item2|Item3|Item4|Item5")     GUICtrlSetData($idCombo_9, "Item1|Item2|Item3|Item4|Item5") now i need this example but create them at runtime as there are more than 9 combos what i need thanks in advance kind regards
    • LWC
      By LWC
      I've made a program that relies on IniReadSectionNames. It reads (~3K) Autorun.inf files in the working folder and creates a GUI based on their contents.
      I made sure to revert to a default GUI upon @error.
      But someone (with Windows XP SP3 32-bit) reported to me he always gets the default menu.
      I sent him a FileRead command instead and it works! So seemingly there's no access problem to AutoRun.inf.
      In the following demo code, I always hit success, but he always ends up with semi-success:
      Local $hIniLocation = "Autorun.inf" Local $aSections = IniReadSectionNames($hIniLocation) If @error Then $aSections = FileRead($hIniLocation) if @error then msgbox(48, "Double error", "Alternative access failed too due to:" & @crlf & @error & @crlf & @extended) else msgbox(0, "Semi-success", "IniReadSectionNames failed, but alternativaly this file contains:" & @crlf & @crlf & $aSections) endif else msgbox(0, "Success", "IniReadSectionNames worked!") endif Why is that? Is there something further to check with him?
      Autorun.inf
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening guys
      I am working on a little project, in which I have to retrieve 8000+ rows of data from a table, from a SQLite database, to populate a combobox 
      This is what I tried 'til now, but it still takes about 12 seconds to populate the combobox.
      _SQLite_Exec($objDatabase, "BEGIN TRANSACTION;") If _SQLite_GetTable($objDatabase, "SELECT DISTINCT Comune FROM LISTA_COMUNI;", $arrRisultatoQuery, $intRighe, $intColonne) = $SQLITE_OK Then For $i = 2 To UBound($arrRisultatoQuery) - 1 If $i < UBound($arrRisultatoQuery) - 1 Then GUICtrlSetData($cbo_ComuneNascita, $arrRisultatoQuery[$i] & "|") Else GUICtrlSetData($cbo_ComuneNascita, $arrRisultatoQuery[$i]) EndIf Next _SQLite_Exec($objDatabase, "COMMIT;") Are there any other solution to retrieve 8000+ records from a SQLite database?
      Thank you very much  
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning community!
      I was working on a script which read the content of a .ini file to retrieve the file that has to open, and, based on the value of a second key stored in the .ini file, set the window on top, minimized or maximized...
      I did something like this, but seems to not work properly...
      Could anyone please tell me what I'm doing wrong?
      Thank you  
       
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_x64=prova.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> ;#include <WinAPIEx.au3> #include <Array.au3> Local $sFileConfigurazione = @ScriptDir & "\configurazione_exe.ini" If(FileExists($sFileConfigurazione)) Then Local $aSezioneIni = IniReadSection($sFileConfigurazione, "CONFIGURAZIONE_EXE") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file: " & @CRLF & $sFileConfigurazione & @CRLF & "Errore: " & @error) Else ; Lancio dell'applicativo indicato nel file di configurazione Local $iPID = ShellExecute($aSezioneIni[1][1]) Local $hWnd If($iPID <> 0) Then Local $aWinList = WinList() For $i = 1 To $aWinList[0][0] If(WinGetProcess($aWinList[$i][1] = $iPID)) Then $hWnd = $aWinList[$i][1] EndIf Next Switch($aSezioneIni[2][1]) Case $aSezioneIni[2][1] = "MIN" ToolTip("MIN", 0, 0) WinSetState($hWnd, WinGetTitle($hWnd), @SW_MINIMIZE) Case $aSezioneIni[2][1] = "MAX" ToolTip("MAX", 0, 0) WinSetState($hWnd, WinGetTitle($hWnd), @SW_MAXIMIZE) Case $aSezioneIni[2][1] = "TOP" ToolTip("TOP", 0, 0) WinSetOnTop($hWnd, WinGetTitle($hWnd), $WINDOWS_ONTOP) EndSwitch EndIf EndIf EndIf And the .ini file is like this:
       
      [CONFIGURAZIONE_EXE] PercorsoExe=Here goes the path and the .exe to execute ModalitaAperturaExe=Here goes one of the value below /* TOP Shows the windows on top */ /* MIN Shows the window minimized */ /* MAX Shows the window maximized */  
    • satanico64
      By satanico64
      Hi huys !
       how are you ? family ? dog, cat ? well..
       
      I've got a problem: _GUICtrlComboBox_GetCueBanner
      i can't get it to work.
      Simple: even the example from help does'nt work...
       
      I insist, it's excactly the example from the help, no modifications
      #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_idMemo Example() Func Example() Local $idCombo ; Create GUI GUICreate("ComboBox Get Count", 400, 296) $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) _GUICtrlComboBox_SetCueBanner($idCombo, "Select an Item") $g_idMemo = GUICtrlCreateEdit("", 10, 50, 376, 234, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Add files _GUICtrlComboBox_BeginUpdate($idCombo) _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe") _GUICtrlComboBox_EndUpdate($idCombo) MemoWrite("Cue Banner: " & _GUICtrlComboBox_GetCueBanner($idCombo)) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite I also added the display of the cuebanner in the loop.
      It never display what actually appears in the combo
      If you can show me any king of working example.
      Thanks Guys !
      Nicolas.
      Actually autoit v3.3.14.2