Etwas eintragen und als txt datei speichern

  • So hallo alle miteinander, ich bin seit paar tagen damit beschäftigt mir ein kleines Programm zu schreiben um paar sachen zu speichern :) ich komme aber absolut nicht weiter :/ hier mal der quellcode

    Spoiler anzeigen
    [autoit][/autoit]

    #include <GUIConstants.au3>
    #include <Timers.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>

    #Region ### START Koda GUI section ### Form=c:\users\marko\desktop\gameforge\form1.kxf

    Opt("GUIOnEventMode", 1)

    $Form1_1 = GUICreate("Verwaltung", 800, 600, 212, 125)
    $Time = GUICtrlCreateLabel("", 650, 4, 80, 20)
    GUICtrlSetColor(-1, 0x008000)
    GUISetState(@SW_SHOW)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial Narrow")
    $Timer1= _Timer_SetTimer($Form1_1, 1000, "_UpdateStatusBarClock")
    Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    GUICtrlSetData($Time, StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC))
    EndFunc
    Func _exit()
    Exit
    EndFunc ;==>_exit

    GUISetOnEvent(-3, "_exit")

    GUICtrlCreateTab(3, 3, 797, 595)

    GUICtrlCreateTabItem("Angaben")
    $Label1 = GUICtrlCreateLabel("Charname:", 40, 40, 84, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Char = GUICtrlCreateInput("", 150, 40, 153, 21)
    $Label2 = GUICtrlCreateLabel("Accountname:", 399, 40, 101, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $ACC = GUICtrlCreateInput("", 500, 40, 129, 21)
    $Label3 = GUICtrlCreateLabel("Server:", 40, 72, 110, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Server = GUICtrlCreateCombo("", 150, 72, 105, 25)
    GUICtrlSetData(-1, "1|2|3|4|")
    $erstellen = GUICtrlCreateButton("Eintragen", 40, 500, 97, 33, 0)
    GUICtrlCreateTabItem("Account")
    GUISetState(@SW_SHOW)

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

    Erstmal muss ich immer auf den 2ten Tab klicken und dann wieder zum ersten bevor dieser etwas anzeigt, dann hätte ich es gerne das wenn ich bei charname und acc ,server usw was eintrage und dann auf eintragen klicke das er mir eine txt datei mit den eingegebenen werten anlegt und als name dann zb der acc name.später füge ich noch mehr hinzu aber is jetzt nur damit ich verstehe wie das ganze funktioniert...

  • 1 Fehler:
    Zeile 14. Diesen Befehl verwendest du zweimal für deine GUI.

    [autoit]

    GUISetState(@SW_SHOW)

    [/autoit]

    Um ein bestimmten Tab zuerst anzeigen zu lassen brauchst du den Befehl:

    [autoit]

    GUICtrlSetState(-1, $GUI_SHOW)

    [/autoit]

    Um die Werte der einzelnen GUI Elemte auszulesen, brauchst du den Befehl:

    [autoit]

    GUICtrlRead(controlID, advanced = 0)

    [/autoit]

    Evtl. machst du zuerst ein Tutorial und liest dir die wirklich gute AutoIt Hilfe durch.

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #include <Timers.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1_1 = GUICreate("Verwaltung", 800, 600, 212, 125)

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

    $Time = GUICtrlCreateLabel("", 650, 4, 80, 20)
    GUICtrlSetColor(-1, 0x008000)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial Narrow")

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

    ;----------------------------------------------------------------------------------------------/
    ; Tab
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTab(3, 3, 797, 595)

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

    ;----------------------------------------------------------------------------------------------/
    ; TabItem 1
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTabItem("Angaben")
    GUICtrlSetState(-1, $GUI_SHOW)

    $Label1 = GUICtrlCreateLabel("Charname:", 40, 40, 84, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $Char = GUICtrlCreateInput("", 150, 40, 153, 21)

    $Label2 = GUICtrlCreateLabel("Accountname:", 399, 40, 101, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $ACC = GUICtrlCreateInput("", 500, 40, 129, 21)

    $Label3 = GUICtrlCreateLabel("Server:", 40, 72, 110, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $Server = GUICtrlCreateCombo("", 150, 72, 105, 25)
    GUICtrlSetData(-1, "1|2|3|4|")

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

    $erstellen = GUICtrlCreateButton("Eintragen", 40, 500, 97, 33, 0)

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

    ;----------------------------------------------------------------------------------------------/
    ; Tab 2
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTabItem("Account")

    GUISetState(@SW_SHOW)

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

    ;----------------------------------------------------------------------------------------------/
    ; set on event
    ;----------------------------------------------------------------------------------------------/
    GUISetOnEvent(-3, "_exit")

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

    ;----------------------------------------------------------------------------------------------/
    ; Timer
    ;----------------------------------------------------------------------------------------------/
    $Timer1 = _Timer_SetTimer($Form1_1, 1000, "_UpdateStatusBarClock")

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

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

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

    Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    GUICtrlSetData($Time, StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC))
    EndFunc

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

    Func _exit()
    Exit
    EndFunc ;==>_exit

    [/autoit]
  • ja das

    [autoit]

    GUICtrlRead(controlID, advanced = 0)

    [/autoit]


    nur es richtig zu benutzen so das alles dort ist wo es hin soll habe ich nicht hinbekommen
    es sollte dann noch in eine Textdatei geschrieben werden in der anordnung:
    Charname:testchar
    Accountname:test
    Server:4

    [spoiler]

    [autoit]

    #include <GUIConstants.au3>
    #include <Timers.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1_1 = GUICreate("Verwaltung", 800, 600, 212, 125)

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

    $Time = GUICtrlCreateLabel("", 650, 4, 80, 20)
    GUICtrlSetColor(-1, 0x008000)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial Narrow")

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

    ;----------------------------------------------------------------------------------------------/
    ; Tab
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTab(3, 3, 797, 595)

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

    ;----------------------------------------------------------------------------------------------/
    ; TabItem 1
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTabItem("Angaben")
    GUICtrlSetState(-1, $GUI_SHOW)

    $Label1 = GUICtrlCreateLabel("Charname:", 40, 40, 84, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $Char = GUICtrlCreateInput("", 150, 40, 153, 21)

    $Label2 = GUICtrlCreateLabel("Accountname:", 399, 40, 101, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $ACC = GUICtrlCreateInput("", 500, 40, 129, 21)

    $Label3 = GUICtrlCreateLabel("Server:", 40, 72, 110, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $Server = GUICtrlCreateCombo("", 150, 72, 105, 25)
    GUICtrlSetData(-1, "1|2|3|4|")

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

    $erstellen = GUICtrlCreateButton("Eintragen", 40, 500, 97, 33, 0)

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

    ;----------------------------------------------------------------------------------------------/
    ; Tab 2
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTabItem("Account")

    GUISetState(@SW_SHOW)

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

    ;----------------------------------------------------------------------------------------------/
    ; set on event
    ;----------------------------------------------------------------------------------------------/
    GUISetOnEvent(-3, "_exit")

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

    ;----------------------------------------------------------------------------------------------/
    ; Timer
    ;----------------------------------------------------------------------------------------------/
    $Timer1 = _Timer_SetTimer($Form1_1, 1000, "_UpdateStatusBarClock")

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $erstellen
    $ACC=GUICtrlRead($Char)
    FileWrite($ACC & ".txt", $ACC)
    EndSwitch
    WEnd

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

    Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    GUICtrlSetData($Time, StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC))
    EndFunc

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

    Func _exit()
    Exit
    EndFunc ;==>_exit

    [/autoit]

    [/spoilich werde mich demnächst mal der hilfe annehmen

  • Bei deinem Vorhaben denke ich wäre eine ini eher geeignet.
    Wie ich sehe vermischt du gerade 2 GUI Varianten. Einmal den Message Loop Modus und einmal den On Event Modus.

    Ich habe jetzt meine Beispiel Funktion mit Absicht sehr sehr einfach gehalten, damit es auch ein Anfänger nachvollziehen kann.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <Timers.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1_1 = GUICreate("Verwaltung", 800, 600, 212, 125)

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

    $Time = GUICtrlCreateLabel("", 650, 4, 80, 20)
    GUICtrlSetColor(-1, 0x008000)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial Narrow")

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

    ;----------------------------------------------------------------------------------------------/
    ; Tab
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTab(3, 3, 797, 595)

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

    ;----------------------------------------------------------------------------------------------/
    ; TabItem 1
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTabItem("Angaben")
    GUICtrlSetState(-1, $GUI_SHOW)

    $Label1 = GUICtrlCreateLabel("Charname:", 40, 40, 84, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $Char = GUICtrlCreateInput("", 150, 40, 153, 21)

    $Label2 = GUICtrlCreateLabel("Accountname:", 399, 40, 101, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $ACC = GUICtrlCreateInput("", 500, 40, 129, 21)

    $Label3 = GUICtrlCreateLabel("Server:", 40, 72, 110, 17)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

    $Server = GUICtrlCreateCombo("", 150, 72, 105, 25)
    GUICtrlSetData(-1, "1|2|3|4|")

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

    $erstellen = GUICtrlCreateButton("Eintragen", 40, 500, 97, 33, 0)

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

    ;----------------------------------------------------------------------------------------------/
    ; Tab 2
    ;----------------------------------------------------------------------------------------------/
    GUICtrlCreateTabItem("Account")

    GUISetState(@SW_SHOW)

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

    ;----------------------------------------------------------------------------------------------/
    ; set on event
    ;----------------------------------------------------------------------------------------------/
    GUISetOnEvent(-3, "_exit")
    GUISetOnEvent($erstellen, "_eintragen")

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

    ;----------------------------------------------------------------------------------------------/
    ; Timer
    ;----------------------------------------------------------------------------------------------/
    $Timer1 = _Timer_SetTimer($Form1_1, 1000, "_UpdateStatusBarClock")

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

    While 1
    sleep(10)
    WEnd

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

    Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    GUICtrlSetData($Time, StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC))
    EndFunc

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

    Func _exit()
    Exit
    EndFunc ;==>_exit

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

    func _eintragen()

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

    Local Static $f_ini = @scriptdir & '\test.ini'

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

    $s_ACC = GUICtrlRead($ACC)
    $s_Char = GUICtrlRead($Char)
    $s_Server = GUICtrlRead($Server)

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

    IniWrite($f_ini, 'Deine Section', 'Account', $s_ACC)
    IniWrite($f_ini, 'Deine Section', 'Charname', $s_Char)
    IniWrite($f_ini, 'Deine Section', 'Accountname', $s_Server)

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

    endfunc

    [/autoit]
  • Mit einer ini datei hab ich es auch hinbekommen gehabt aber ich wollte es gerne in einer textdatei^^ aber ok danke :). Achja, wenn ich die sache mit den Tabs weglasse dann schreibt er es auch in eine textdatei^^

  • Hast du dir die Hilfe überhaupt angeschaut und die dazugehörigen Beispiele? Denn genau dafür was du vorhast existiert ein Beispiel. Du musst nur einpaar Code Zeilen in der Funktion anpassen.... Das kriegt wirklich jeder Google Entwickler hin...

    Für jeden Anfänger empfehle ich dieses hervoragende AutoIt Buch durchzulesen!!! Vor ca. einem Jahr habe ich auch mit AutoIt angefangen und dieses Buch hat mir ziemlich oft weitergeholfen.

  • schau gerad in dem autoit buch rein, bin mir noch nicht sicher was für eine sprache ich lerne.. hab schon bei java und c++ reingeschaut. Hatte mich vor jahren schonmal mit autoit befasst und darum wollt ich damit nur "schnell" das kleine tool fertig machen und dann inruhe mich für eine sprache entscheiden. Ist iwo bei dem code ein fehler da er die ini nicht ausspuckt ?