ListView auslesen + Inputfeld und anschließend in eine .txt schreiben ?

  • Hallo Liebe Gemeinde wie könnte ich aus folgendem script die 2te Listview auslesen,
    in eine txt aufm desktop schreiben
    den inputfeld Auslesen
    und das in der letzten zeile der zuvor erstellten Datei anhängen ?

    Vielen Dank im Vorraus

    MFG Eistee

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListBoxConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIListBox.au3>
    #NoTrayIcon

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

    DirCreate("C:\BS\EK-RECHNER\DB")
    DirCreate("C:\BS\EK-RECHNER\NEU")
    DirCreate("C:\BS\EK-RECHNER\PIC")
    FileInstall("NEU.exe", @ScriptDir & "\NEU.exe")
    FileInstall("Spaghetti.txt", "C:\BS\EK-RECHNER\DB\Spaghetti.txt")
    FileInstall("HackFleisch.txt", "C:\BS\EK-RECHNER\DB\HackFleisch.txt")
    FileInstall("BG.jpg", "C:\BS\EK-RECHNER\PIC\BG.jpg")

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

    $search = FileFindFirstFile("C:\BS\EK-RECHNER\DB" & "\*.*")

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

    While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $F1 = FileOpen("C:\1.txt", 1)
    FileWrite($F1, $file)
    FileClose($F1)
    $file1 = FileRead("C:\1.txt")
    $file2 = StringRegExpReplace($file1, '.txt', "|")
    WEnd

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

    $Form1 = GUICreate("EinkaufsRechner", 400, 345, -1, -1)
    GUISetBkColor(0x000000)
    $List1 = GUICtrlCreateList("", 8, 28, 160, 240)
    GUICtrlSetData(-1, $file2)
    $List2 = GUICtrlCreateList("", 230, 28, 160, 240)
    $hlist2 = GUICtrlGetHandle($List2)
    $Button1 = GUICtrlCreateButton(">", 184, 124, 30, 25, 0)
    $Button2 = GUICtrlCreateButton("Clear", 179, 164, 40, 25, 0)
    $Input1 = GUICtrlCreateInput("Preis Einkauf in €", 230, 270, 160, 25)
    $Button3 = GUICtrlCreateButton("Neuer Artikel", 8, 270, 160, 25, 0)
    $Button4 = GUICtrlCreateButton("Druck Einkauf", 148, 309, 100, 25, 0)
    $Pic1 = GUICtrlCreatePic("C:\BS\EK-RECHNER\PIC\BG.jpg", 0, 0, 400, 345, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS, $WS_DISABLED))
    GUICtrlCreateLabel("Artikel",12,8)
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateLabel("Einkaufs Liste",234,8)
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
    GUISetState(@SW_SHOW)

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

    AdlibEnable("_5", 1050)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    FileDelete(@ScriptDir & "\NEU.exe")
    FileDelete("C:\1.txt")
    Exit
    Case $Button1
    _1()
    Case $Button2
    _2()
    Case $Button3
    _3()
    Case $Button4
    _4()
    EndSwitch
    WEnd

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

    Func _1()
    GUICtrlSetData($List2, GUICtrlRead($List1))
    EndFunc ;==>_1

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

    Func _2()
    GUICtrlSetData($List2, "")
    EndFunc ;==>_2

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

    Func _3 ()
    ShellExecute(@ScriptDir & "\NEU.exe")
    FileDelete("C:\1.txt")
    Exit
    EndFunc

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

    Func _4()

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

    EndFunc

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

    Func _5()
    Local $price
    Local $lcount = _GUICtrlListBox_GetCount($hlist2)
    For $i = 1 To $lcount
    Local $open = FileOpen("C:\BS\EK-RECHNER\DB\" & _GUICtrlListBox_GetText($hlist2, $i - 1) & ".txt", 0)
    Local $read = FileReadLine($open, 2)

    $price += StringReplace($read, ",", ".")
    FileClose($open)
    Next
    GUICtrlSetData($Input1, $price & " €")
    $preis = ""
    EndFunc

    [/autoit]
  • Mhm Funktion 5 ist doch schon ganz nah dran.

    [autoit]

    Func _5()
    Local $lcount = _GUICtrlListBox_GetCount($hlist2)
    Local $open = FileOpen("", 2) ;den Pfad zum File noch angeben, ggf noch erstellen mit _FileCreate
    For $i = 1 To $lcount
    FileWriteLine($open,_GUICtrlListBox_GetText($hlist2, $i - 1))
    Next
    FileWriteLine($open,GUICtrlRead($input1)
    FileClose($open)
    EndFunc

    [/autoit]