Hilfe bei Combobox und unendlich Werte in .ini

  • Ich hab einen Wert über eine Inputbox in eine .ini schreiben lassen:

    [autoit]

    $write1 = InputBox("iwas", "muh")
    IniWrite(@ScriptDir & "\config.ini", "bla", "blu", $write1)

    [/autoit]


    Jetzt will ich unendlich Einträge unter der Sektion speichern...

    Danach soll das ganze automatisch in einer Combobox erscheinen, und je nach Wert ein dazu passender Wert in einen Input geschrieben werden.


    Besonders letzeres bereitet mir Kopfzerbrechen... bitte helfen.

  • Hallo mipez,

    hier einmal ein Beispiel wie man URLs in einer Combo (mit Hilfe einer INI) verwalten kann:

    Spoiler anzeigen
    [autoit]

    ;#include <GuiComboBox.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <IE.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #include <File.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Const $sElect = "bitte eine URL auswählen"
    Global $URL

    [/autoit] [autoit][/autoit] [autoit]

    If Not FileExists(@ScriptDir & "\URL.INI") Then
    $sData = "AutoIt=http://www.autoit.de" & @LF & "Der Thread=http://www.autoit.de/index.php?page=Thread&postID=122400#post122400" & @LF & "AutoIt V3=http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe"
    IniWriteSection(@ScriptDir & "\URL.INI", "URLs", $sData)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Combobox mit INI ", 300, 160, 302, 218)
    $hcboProg = GUICtrlCreateCombo($sElect, 8, 8, 200, 25)
    $hbtnAdd = GUICtrlCreateButton("&Hinzufügen", 213, 8)
    $hlblURL = GUICtrlCreateLabel("", 8, 35, 200, 50)
    $list1 = IniReadSection(@ScriptDir & "\URL.INI", "URLs")
    ConsoleWrite($list1 & @CRLF)
    For $i = 1 To $list1[0][0]
    GUICtrlSetData($hcboProg, $list1[$i][0])
    Next
    $hbtnOpen = GUICtrlCreateButton("&Öffnen", 8, 85)
    GUICtrlSetState($hbtnOpen, $GUI_DISABLE)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $hbtnAdd
    $write1 = InputBox("URL", "Bitte eine gülzige eingeben")
    If $write1 <> "" Then
    $write2 = InputBox("URL verwalten unter", "Bitte Kurzbegriff eingeben")
    If $write2 <> "" Then IniWrite(@ScriptDir & "\URL.INI", "URLs", $write2, $write1)
    GUICtrlSetData($hcboProg, $write2, $write2)
    EndIf
    show_Selection()
    Case $hcboProg
    show_Selection()
    Case $hbtnOpen
    ;hier $URL öffnen
    ConsoleWrite($URL & @CRLF)
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func show_Selection()
    If GUICtrlRead($hcboProg) = $sElect Then
    GUICtrlSetState($hbtnOpen, $GUI_DISABLE)
    GUICtrlSetData($hlblURL, "")
    Else
    GUICtrlSetState($hbtnOpen, $GUI_ENABLE)
    $Prog = GUICtrlRead($hcboProg)
    ConsoleWrite("ausgewählt: " & $Prog & @CRLF)
    $URL = IniRead(@ScriptDir & "\URL.INI", "URLs", $Prog, "")
    GUICtrlSetData($hlblURL, $URL)
    EndIf
    EndFunc ;==>show_Selection

    [/autoit]

    viel Spass damit,

    mfg (Auto)Bert

  • Danke AutoBert, aber das hat mir bis jetzt (noch) nicht geholfen...

    Spoiler anzeigen
    [autoit]


    #RequireAdmin
    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $Auto = GUICreate("Auto-Login by mipez ver. 2.0", 571, 281, 193, 125)
    GUISetFont(12, 400, 0, "Tahoma")
    GUISetBkColor(0xC0DCC0)

    [/autoit] [autoit][/autoit] [autoit]

    $resolution = GUICtrlCreateCombo("resolution", 16, 24, 153, 27)
    GUICtrlSetData(-1, "1440x900")
    $server = GUICtrlCreateCombo("server", 193, 24, 153, 27)
    GUICtrlSetData(-1,"English|German|French|Russian, Polish, Turkish|Spain, Italian, Portuguese")
    $channel = GUICtrlCreateCombo("channel", 370, 24, 153, 27)
    GUICtrlSetData(-1,"Rookie|Super Rookie|Pro|Free|Free 2|Free 3|Free 4")
    $id = GUICtrlCreateCombo("id", 16, 106, 153, 27)

    [/autoit] [autoit][/autoit] [autoit]

    $loadevery1 = GUICtrlCreateCheckbox("Want to load this every time?", 16, 68, 233, 17)
    $loadevery2 = GUICtrlCreateCheckbox("Want to load this every time?", 16, 195, 233, 17)
    $windowed = GUICtrlCreateCheckbox("Windowed", 16, 235, 105, 17)
    $news = GUICtrlCreateCheckbox("Click Announcement", 140, 235, 180, 17)

    [/autoit] [autoit][/autoit] [autoit]

    $pw = GUICtrlCreateInput("PW", 193, 106, 153, 27)
    $path = GUICtrlCreateInput("Path", 16, 152, 329, 27)

    [/autoit] [autoit][/autoit] [autoit]

    $save1 = GUICtrlCreateButton("Save", 368, 106, 80, 27, 0)
    $load1 = GUICtrlCreateButton("Load", 458, 106, 80, 27, 0)
    $getpath = GUICtrlCreateButton("Get", 368, 152, 48, 27, 0)
    $savepath = GUICtrlCreateButton("Save", 422, 152, 56, 27, 0)
    $loadpath = GUICtrlCreateButton("Load", 482, 152, 56, 27, 0)
    $start = GUICtrlCreateButton("Start", 336, 200, 193, 57, 0)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Switch $msg

    [/autoit] [autoit][/autoit] [autoit]

    Case $GUI_EVENT_CLOSE
    GUIDelete()
    Exit
    EndSwitch
    WEnd

    [/autoit]


    So soll das aussehen bzw. sieht es schon aus... Wenn man auf "Save" klickt, kann man per Inputbox eine neue ID und ein neues PW speichern. Wenn man auf "Load" klickt, wird passend zu der ID in der Combobox das PW geladen.

    3 Mal editiert, zuletzt von mipez (3. April 2010 um 23:00)

  • Hallo mipez,

    lässt sich doch ganz einfach übertragen:

    Spoiler anzeigen
    [autoit]

    #RequireAdmin
    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $sIni = @ScriptDir & "\Config.INI", $oldID

    [/autoit] [autoit][/autoit] [autoit]

    $Auto = GUICreate("Auto-Login by mipez ver. 2.0", 571, 281, 193, 125)
    GUISetFont(12, 400, 0, "Tahoma")
    GUISetBkColor(0xC0DCC0)

    [/autoit] [autoit][/autoit] [autoit]

    $resolution = GUICtrlCreateCombo("resolution", 16, 24, 153, 27)
    GUICtrlSetData(-1, "1440x900")
    $server = GUICtrlCreateCombo("server", 193, 24, 153, 27)
    GUICtrlSetData(-1, "English|German|French|Russian, Polish, Turkish|Spain, Italian, Portuguese")
    $channel = GUICtrlCreateCombo("channel", 370, 24, 153, 27)
    GUICtrlSetData(-1, "Rookie|Super Rookie|Pro|Free|Free 2|Free 3|Free 4")
    $loadevery1 = GUICtrlCreateCheckbox("Want to load this every time?", 16, 68, 233, 17)

    [/autoit] [autoit][/autoit] [autoit]

    $id = GUICtrlCreateCombo("id", 16, 106, 153, 27)
    $list1 = IniReadSection($sIni, "IDs")
    ConsoleWrite($list1 & @CRLF)
    If IsArray($list1) Then
    For $i = 1 To $list1[0][0]
    GUICtrlSetData($id, $list1[$i][0])
    Next
    EndIf
    $pw = GUICtrlCreateInput("PW", 193, 106, 153, 27)
    $save1 = GUICtrlCreateButton("Save", 368, 106, 80, 27, 0)
    $load1 = GUICtrlCreateButton("Load", 458, 106, 80, 27, 0)

    [/autoit] [autoit][/autoit] [autoit]

    $path = GUICtrlCreateInput("Path", 16, 152, 329, 27)
    $getpath = GUICtrlCreateButton("Get", 368, 152, 48, 27, 0)
    $savepath = GUICtrlCreateButton("Save", 422, 152, 56, 27, 0)
    $loadpath = GUICtrlCreateButton("Load", 482, 152, 56, 27, 0)

    [/autoit] [autoit][/autoit] [autoit]

    $loadevery2 = GUICtrlCreateCheckbox("Want to load this every time?", 16, 195, 233, 17)
    $windowed = GUICtrlCreateCheckbox("Windowed", 16, 235, 105, 17)
    $news = GUICtrlCreateCheckbox("Click Announcement", 140, 235, 180, 17)

    [/autoit] [autoit][/autoit] [autoit]

    $start = GUICtrlCreateButton("Start", 336, 200, 193, 57, 0)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    GUIDelete()
    Exit
    case $id, $load1
    show_Selection()
    Case $save1
    $writeID = GUICtrlRead($id)
    If $writeID <> "" Then
    $writePW = GUICtrlRead($pw)
    If $writePW <> "" Then IniWrite($sIni, "IDs", $writeID, $writePW)
    GUICtrlSetData($id, $writeID, $writeID)
    EndIf
    show_Selection()
    EndSwitch
    #cs
    if GUICtrlRead($id) <> $oldID Then ;nach jeder Änderung im Feld ID
    show_Selection()
    $oldID = GUICtrlRead($id)
    EndIf
    #ce
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func show_Selection()
    Local $readID, $readPW
    If GUICtrlRead($id) = "ID" Then
    GUICtrlSetState($save1, $GUI_DISABLE)
    GUICtrlSetData($pw, "")
    Else
    GUICtrlSetState($save1, $GUI_ENABLE)
    $readID = GUICtrlRead($id)
    $readPW = IniRead($sIni, "IDs", $readID, "")
    GUICtrlSetData($pw, $readPW)
    EndIf
    EndFunc ;==>show_Selection

    [/autoit]

    mfg (Auto)Bert

  • Ich glaub ich benutz erstmal 2 normale Inputs... für Checkbox in Verbindung mit ner .ini reicht mein Wissen bei weitem nicht aus .__.
    Trotzdem vielen Dank.