Altes Tabitem auslesen?

  • Hallo Liebes Autoit Team

    Mein Problem ist folgendes.Ich habe ein Programm geschrieben,das wenn man auf Eintrag erstellen drückt,ein neues Tabitem gemacht wird.Wenn man dann von einem Tabitem zum anderen wechselt,wird man gefragt ob man speichern möchte.Soweit so gut.Doch wann man dann ja wählt,soll das vorhrige Tabitem ausgewählt werden.Und das ist das Problem.Wie soll ich das anstellen.Ich habe es schon mit _GUICtrlTab_GetCurSel versucht.Aber das hilft auch nicht

    Einmal editiert, zuletzt von Gothic30381 (26. Mai 2010 um 15:10)

  • Ok.Ich stelle mal mein ganzes Script rein

    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiTab.au3>
    #include <GuiListView.au3>

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

    Global $Title = "Cow Worker"
    Global $MainCostTogehterGlobal = "-"
    Global $Entrys = 1
    Global $Klick = 0
    Global $NowFile
    Global $NowFile2
    Global $NowFile3
    Global $NowFile4
    Global $KorrektLoad
    Global $LoadMode
    Global $WithnoCWC = False
    Global $TabMode

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

    Global $EncryptCowName
    Global $EncryptCowEarNumber
    Global $EncryptDate
    Global $EncryptMedikament
    Global $EncryptDosierung
    Global $EncryptCost

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

    Global $DecryptCowName
    Global $DecryptEarNumber
    Global $DecryptDate
    Global $DecryptMedikament
    Global $DecryptDosierung
    Global $DecryptCost

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

    $FavoriteListRead = FileRead(@ScriptDir & "\FavoritList.ini")
    If @error Then
    FileWrite(@ScriptDir & "\FavoritList.ini","Medikament")
    EndIf
    If FileReadLine(@ScriptDir & "\FavoritList.ini",1) = "" Then
    If FileExists(@ScriptDir & "\FavoritList.ini") Then
    FileDelete(@ScriptDir & "\FavoritList.ini")
    FileWrite(@ScriptDir & "\FavoritList.ini","Medikament")
    Else
    FileWrite(@ScriptDir & "\FavoritList.ini","Medikament")
    EndIf
    EndIf
    _OptionsCheck()

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

    $FavoriteListRead = ""
    $FavoriteListRead = FileRead(@ScriptDir & "\FavoritList.ini")

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

    #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Scripts\Cow worker\Cow_Worker_Main_Window.kxf
    $Form1 = GUICreate($Title, 499, 542, -1, -1)
    GUICtrlCreateLabel("Kuh name:", 8, 48, 105, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $CowName = GUICtrlCreateInput("", 8, 80, 161, 21)
    GUICtrlCreateLabel("Ohrmarkennummer:", 8, 112, 191, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $CowEarNumber = GUICtrlCreateInput("", 8, 144, 161, 21)
    GUICtrlCreateLabel("Datum:", 8, 176, 69, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Date = GUICtrlCreateInput("", 8, 208, 161, 21)
    GUICtrlCreateLabel("Medikament:", 8, 240, 123, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Medikament = GUICtrlCreateInput("", 8, 272, 161, 21)
    GUICtrlCreateLabel("Dosierung:", 8, 304, 106, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Dosierung = GUICtrlCreateInput("", 8, 336, 161, 21)
    $Combo1 = GUICtrlCreateCombo("", 328, 272, 145, 25)
    $ToMedikamentFavorite = GUICtrlCreateButton("Medikament zur Favoritenliste", 176, 272, 145, 25, $WS_GROUP)
    GUICtrlCreateLabel("Kosten:", 8, 368, 74, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Cost = GUICtrlCreateInput("", 8, 400, 161, 21)
    $MainCost = GUICtrlCreateLabel("Gesamtkosten: " & $MainCostTogehterGlobal, 176, 440, 3941, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $SaveCow = GUICtrlCreateButton("Kuh und Eintrag speichern", 72, 504, 129, 25, $WS_GROUP)
    $LoadCow = GUICtrlCreateButton("Eine Kuh laden", 200, 504, 129, 25, $WS_GROUP)
    $NewEntry = GUICtrlCreateButton("Eintrag erstellen", 328, 504, 113, 25, $WS_GROUP)
    $GenerateDate = GUICtrlCreateButton("Heutiges Datum eintragen", 176, 208, 137, 25, $WS_GROUP)
    $Tab1 = GUICtrlCreateTab(0, 16, 489, 25)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    GUICtrlCreateTabItem("Eintrag1")
    $List1 = GUICtrlCreateList("", 240, 56, 241, 149)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    GUICtrlSetData($Combo1,$FavoriteListRead)
    GUICtrlSetData($List1,"Eintrag1")
    ;HotKeySet("{w}","_LoadEntrys")
    If $TabMode = True Then
    GUICtrlSetState($List1,$GUI_HIDE)
    Else
    GUICtrlSetState($Tab1,$GUI_HIDE)
    EndIf
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Combo1
    If GUICtrlRead($Combo1) = "Medikament" Or GUICtrlRead($Combo1) = "|Medikament" Then
    MsgBox(16,"Achtung!","Das angegebene Medikament ist kein Medikament!",$Form1,$Form1)
    Else
    $Ask1 = MsgBox(68,"Verwenden?","Möchten sie " & GUICtrlRead($Combo1) & " als Medikament verwenden?",$Form1,$Form1)
    If $Ask1 = 6 Then
    GUICtrlSetData($Medikament,GUICtrlRead($Combo1))
    EndIf
    EndIf
    Case $ToMedikamentFavorite
    If GUICtrlRead($Medikament) = "" Then
    MsgBox(16,"Achtung!","Bitte geben sie ein Medikament ein!",$Form1,$Form1)
    Else
    $Ask2 = MsgBox(68,"Verwenden?","Möchten sie " & GUICtrlRead($Medikament) & " hinzufügen?",$Form1,$Form1)
    If $Ask2 = 6 Then
    If StringInStr($FavoriteListRead,GUICtrlRead($Medikament)) Then
    MsgBox(16,"Achtung!","Dieses Medikament exestiert bereits!",$Form1,$Form1)
    Else
    FileWrite(@ScriptDir & "\FavoritList.ini",@CRLF & "|" & GUICtrlRead($Medikament))
    GUICtrlSetData($Combo1,"")
    GUICtrlSetData($Combo1,FileRead(@ScriptDir & "\FavoritList.ini"))
    MsgBox(64,"Info","Medikament " & GUICtrlRead($Medikament) & " hinzugefügt!",$Form1,$Form1)
    EndIf
    EndIf
    EndIf
    Case $Tab1
    If $NowFile = "" Then
    MsgBox(16,"Achtung!","Bitte speichern sie bevor sie einen Eintrag wählen!",$Form1,$Form1)
    Else
    $Ask4 = MsgBox(68,"Speichern?","Möchten sie speichern bevor sie den Eintrag wechseln?",$Form1,$Form1)
    If $Ask4 = 6 Then
    ;Hier soll dann das vorhrige Tab gewählt werden
    EndIf
    EndIf
    ;_LoadDataforEntrys()
    Case $List1
    If $NowFile = "" Then
    MsgBox(16,"Achtung!","Bitte speichern sie bevor sie einen Eintrag wählen!",$Form1,$Form1)
    Else
    $Ask3 = MsgBox(68,"Speichern?","Möchten sie speichern bevor sie einen einen anderen Eintrag wählen?",$Form1,$Form1)
    If $Ask3 = 7 Then
    _ContinueSave()
    EndIf
    EndIf
    _LoadDataforEntrys2()

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

    Case $SaveCow
    If GUICtrlRead($CowName) = "" Then
    MsgBox(16,"Achtung!","Bitte geben sie einen Kuhnamen an!",$Form1,$Form1)
    Else
    If GUICtrlRead($CowEarNumber) = "" Then
    GUICtrlSetData($CowEarNumber,"-")
    EndIf
    If GUICtrlRead($Date) = "" Then
    GUICtrlSetData($Date,"-")
    EndIf
    If GUICtrlRead($Medikament) = "" Then
    GUICtrlSetData($Medikament,"-")
    EndIf
    If GUICtrlRead($Dosierung) = "" Then
    GUICtrlSetData($Dosierung,"-")
    EndIf
    If GUICtrlRead($Cost) = "" Then
    GUICtrlSetData($Cost,"-")
    EndIf
    If $TabMode = True Then
    _ContinueSave()
    Else
    _ContinueSave2()
    EndIf
    EndIf
    Case $LoadCow
    If $TabMode = True Then
    _LoadCow1()
    Else
    _LoadCow2()
    EndIf
    Case $NewEntry
    If $NowFile = "" Then
    MsgBox(16,"Achtung!","Bitte speichern sie bevor sie einen neuen Eintrag erstellen!",$Form1,$Form1)
    Else
    $Entrys += 1
    If $TabMode = True Then
    GUICtrlCreateTabItem("Eintrag" & $Entrys)
    Else
    GUICtrlSetData($List1,"Eintrag" & $Entrys)
    EndIf
    EndIf
    Case $GenerateDate
    GUICtrlSetData($Date,@MDAY & "." & @MON & "." & @YEAR & " " & @HOUR & ":" & @MIN)

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

    EndSwitch
    WEnd

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

    Func _LoadEntrys()
    SplashTextOn("","Bitte warten...")
    ;GUISetState(@SW_MAXIMIZE,$Form1)
    For $i = 0 To $Entrys
    SplashTextOn("","Bitte warten...")
    $Klick += 1
    ;MouseClick("left",517, 46,1)
    ;Hier werden die Tabs ausgewählt?
    ;SplashOff()
    ;MsgBox(64,"",GUICtrlRead($Medikament))
    Next
    $Klick = 0
    ;GUISetState(@SW_RESTORE,$Form1)
    SplashOff()
    EndFunc

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

    Func _ResetLabels()
    GUICtrlSetData($CowName,"")
    GUICtrlSetData($CowEarNumber,"")
    GUICtrlSetData($Date,"")
    GUICtrlSetData($Medikament,"")
    GUICtrlSetData($Dosierung,"")
    GUICtrlSetData($Cost,"")
    EndFunc

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

    Func _LoadDataforEntrys()
    $NowTab = GUICtrlRead($Tab1)
    $NowTab += 1
    $ReadDataforEntrys1 = IniRead($NowFile,"Eintrag" & $NowTab,"Date","")
    $ReadDataforEntrys2 = IniRead($NowFile,"Eintrag" & $NowTab,"Medikament","")
    $ReadDataforEntrys3 = IniRead($NowFile,"Eintrag" & $NowTab,"Dosierung","")
    $ReadDataforEntrys4 = IniRead($NowFile,"Eintrag" & $NowTab,"Cost","")
    GUICtrlSetData($Date,$ReadDataforEntrys1)
    GUICtrlSetData($Medikament,$ReadDataforEntrys2)
    GUICtrlSetData($Dosierung,$ReadDataforEntrys3)
    GUICtrlSetData($Cost,$ReadDataforEntrys4)
    If $LoadMode = True Then
    If $ReadDataforEntrys1 = "" Or $ReadDataforEntrys2 = "" Or $ReadDataforEntrys3 = "" Or $ReadDataforEntrys4 = "" Then
    SplashOff()
    MsgBox(48,"Warnung!","Einige Daten für Eintrag" & $NowTab & " konnten nicht geladen werden!",$Form1,$Form1)
    $KorrektLoad = False
    Else
    $KorrektLoad = True
    EndIf
    EndIf
    EndFunc

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

    Func _LoadDataforEntrys2()
    $NowTab = GUICtrlRead($List1)
    $ReadDataforEntrys1 = IniRead($NowFile,"Eintrag" & $NowTab,"Date","")
    $ReadDataforEntrys2 = IniRead($NowFile,"Eintrag" & $NowTab,"Medikament","")
    $ReadDataforEntrys3 = IniRead($NowFile,"Eintrag" & $NowTab,"Dosierung","")
    $ReadDataforEntrys4 = IniRead($NowFile,"Eintrag" & $NowTab,"Cost","")
    GUICtrlSetData($Date,$ReadDataforEntrys1)
    GUICtrlSetData($Medikament,$ReadDataforEntrys2)
    GUICtrlSetData($Dosierung,$ReadDataforEntrys3)
    GUICtrlSetData($Cost,$ReadDataforEntrys4)
    If $LoadMode = True Then
    If $ReadDataforEntrys1 = "" Or $ReadDataforEntrys2 = "" Or $ReadDataforEntrys3 = "" Or $ReadDataforEntrys4 = "" Then
    SplashOff()
    MsgBox(48,"Warnung!","Einige Daten für Eintrag" & $NowTab & " konnten nicht geladen werden!",$Form1,$Form1)
    $KorrektLoad = False
    Else
    $KorrektLoad = True
    EndIf
    EndIf
    EndFunc

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

    Func _ContinueSave()
    If $NowFile = "" Then
    $Path = FileSaveDialog("Speichern",@DesktopDir,"Cow Worker Cow Datei(*.cwc)",16,"",$Form1)
    If @error Then
    Else
    If FileExists($Path) Then
    FileDelete($Path)
    $WithnoCWC = True
    EndIf
    SplashTextOn("","Speichern läuft...")
    $NowTab = ""
    $NowTab = GUICtrlRead($Tab1)
    $NowTab += 1
    $NowFile = $Path
    If $WithnoCWC = True Then
    IniWrite($Path,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path,"Other","TreeItems",$Entrys)
    IniWrite($Path,"Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    Else
    IniWrite($Path & ".cwc","Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path & ".cwc","Other","TreeItems",$Entrys)
    IniWrite($Path & ".cwc","Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    EndIf
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    EndIf
    Else
    If FileExists($NowFile) Then
    SplashTextOn("","Speichern läuft...")
    $NowTab = GUICtrlRead($Tab1)
    $NowTab += 1
    IniWrite($NowFile,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($NowFile2,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($NowFile3,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($NowFile4,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))

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

    IniWrite($NowFile,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($NowFile,"Other","TreeItems",$Entrys)
    IniWrite($NowFile,"Other","EarNumber",GUICtrlRead($CowEarNumber))
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    Else
    MsgBox(16,"Achtung!","Die angegebene Datei existiert nicht mehr!",$Form1,$Form1)
    $NowFile = ""
    EndIf
    EndIf
    EndFunc

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

    Func _OptionsCheck()
    If FileExists(@ScriptDir & "\Options.ini") Then
    If IniRead(@ScriptDir & "\Options.ini","Data","TabMode","") = "True" Then
    $TabMode = True
    Else
    $TabMode = False
    EndIf
    Else
    IniWrite(@ScriptDir & "\Options.ini","Data","TabMode","True")
    _OptionsCheck()
    EndIf
    EndFunc

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

    Func _ContinueSave2()
    If $NowFile = "" Then
    $Path = FileSaveDialog("Speichern",@DesktopDir,"Cow Worker Cow Datei(*.cwc)",16,"",$Form1)
    If @error Then
    Else
    If FileExists($Path) Then
    FileDelete($Path)
    $WithnoCWC = True
    EndIf
    SplashTextOn("","Speichern läuft...")
    $NowTab = ""
    $NowTab = GUICtrlRead($List1)
    $NowTab += 1
    $NowFile = $Path
    If $WithnoCWC = True Then
    IniWrite($Path,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path,"Other","TreeItems",$Entrys)
    IniWrite($Path,"Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    Else
    IniWrite($Path & ".cwc","Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path & ".cwc","Other","TreeItems",$Entrys)
    IniWrite($Path & ".cwc","Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    EndIf
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    EndIf
    Else
    If FileExists($NowFile) Then
    SplashTextOn("","Speichern läuft...")
    $NowTab = GUICtrlRead($List1)
    $NowTab += 1
    IniWrite($NowFile,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($NowFile2,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($NowFile3,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($NowFile4,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))

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

    IniWrite($NowFile,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($NowFile,"Other","TreeItems",$Entrys)
    IniWrite($NowFile,"Other","EarNumber",GUICtrlRead($CowEarNumber))
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    Else
    MsgBox(16,"Achtung!","Die angegebene Datei existiert nicht mehr!",$Form1,$Form1)
    $NowFile = ""
    EndIf
    EndIf
    EndFunc

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

    Func _LoadCow1()
    $LoadPath = FileOpenDialog("Eine Kuh laden",@DesktopDir,"Cow Worker Datei(*.cwc)",1,"",$Form1)
    If @error Then
    Else
    GUISetState(@SW_DISABLE,$Form1)
    $TreeItemsRead = IniRead($LoadPath,"Other","TreeItems","")
    If @error Then
    MsgBox(16,"Achtung!","Die Einträge konnten nicht gelesen werden!",$Form1,$Form1)
    GUISetState(@SW_ENABLE,$Form1)
    Else
    SplashTextOn("","Einträge werden entfernt...")
    Sleep(500)
    $LoadMode = True
    $Entrys = 0
    _GUICtrlTab_DeleteAllItems($Tab1)
    _ResetLabels()
    Sleep(500)
    SplashTextOn("","Lade Einträge von Datei " & $LoadPath & ".Dies kann je nach größe der Datei eine Weile dauern...")
    For $i = 1 To $TreeItemsRead
    $Entrys += 1
    GUICtrlCreateTabItem("Eintrag" & $Entrys)
    Next
    GUICtrlSetData($CowName,IniRead($LoadPath,"Other","CowName",""))
    GUICtrlSetData($CowEarNumber,IniRead($LoadPath,"Other","EarNumber",""))
    $NowFile = $LoadPath
    $NowFile2 = $LoadPath
    $NowFile3 = $LoadPath
    $NowFile4 = $LoadPath
    _LoadDataforEntrys()
    SplashOff()
    GUISetState(@SW_ENABLE,$Form1)
    If $KorrektLoad = True Then
    MsgBox(64,"Hinweiß","Die Kuh wurde mit " & IniRead($LoadPath,"Other","TreeItems","") & " Einträge erfolgreich geladen!",$Form1,$Form1)
    Else
    MsgBox(64,"Hinweiß","Die Kuh wurde geladen.Jedoch konnten einige Angaben für Eintrag1 nicht geladen werden.Geladene Tabs:" & IniRead($LoadPath,"Other","TreeItems",""),$Form1,$Form1)
    EndIf
    $LoadMode = False
    EndIf
    EndIf
    EndFunc

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

    Func _LoadCow2()
    $LoadPath = FileOpenDialog("Eine Kuh laden",@DesktopDir,"Cow Worker Datei(*.cwc)",1,"",$Form1)
    If @error Then
    Else
    GUISetState(@SW_DISABLE,$Form1)
    $TreeItemsRead = IniRead($LoadPath,"Other","TreeItems","")
    If @error Then
    MsgBox(16,"Achtung!","Die Einträge konnten nicht gelesen werden!",$Form1,$Form1)
    GUISetState(@SW_ENABLE,$Form1)
    Else
    SplashTextOn("","Einträge werden entfernt...")
    Sleep(500)
    $LoadMode = True
    $Entrys = 0
    GUICtrlSetData($List1,"")
    _ResetLabels()
    Sleep(500)
    SplashTextOn("","Lade Einträge von Datei " & $LoadPath & ".Dies kann je nach größe der Datei eine Weile dauern...")
    For $i = 1 To $TreeItemsRead
    $Entrys += 1
    GUICtrlSetData($List1,"Eintrag" & $Entrys)
    Next
    GUICtrlSetData($CowName,IniRead($LoadPath,"Other","CowName",""))
    GUICtrlSetData($CowEarNumber,IniRead($LoadPath,"Other","EarNumber",""))
    $NowFile = $LoadPath
    $NowFile2 = $LoadPath
    $NowFile3 = $LoadPath
    $NowFile4 = $LoadPath
    _LoadDataforEntrys()
    SplashOff()
    GUISetState(@SW_ENABLE,$Form1)
    If $KorrektLoad = True Then
    MsgBox(64,"Hinweiß","Die Kuh wurde mit " & IniRead($LoadPath,"Other","TreeItems","") & " Einträge erfolgreich geladen!",$Form1,$Form1)
    Else
    MsgBox(64,"Hinweiß","Die Kuh wurde geladen.Jedoch konnten einige Angaben für Eintrag1 nicht geladen werden.Geladene Tabs:" & IniRead($LoadPath,"Other","TreeItems",""),$Form1,$Form1)
    EndIf
    $LoadMode = False
    EndIf
    EndIf
    EndFunc

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

    Func _SaveTab($ReadedTab)
    If $NowFile = "" Then
    $Path = FileSaveDialog("Speichern",@DesktopDir,"Cow Worker Cow Datei(*.cwc)",16,"",$Form1)
    If @error Then
    Else
    If FileExists($Path) Then
    FileDelete($Path)
    $WithnoCWC = True
    EndIf
    SplashTextOn("","Speichern läuft...")
    $NowTab = ""
    $NowTab = $ReadedTab
    $NowTab += 1
    $NowFile = $Path
    If $WithnoCWC = True Then
    IniWrite($Path,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path,"Other","TreeItems",$Entrys)
    IniWrite($Path,"Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    Else
    IniWrite($Path & ".cwc","Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path & ".cwc","Other","TreeItems",$Entrys)
    IniWrite($Path & ".cwc","Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    EndIf
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    EndIf
    Else
    If FileExists($NowFile) Then
    SplashTextOn("","Speichern läuft...")
    $NowTab = $ReadedTab
    $NowTab += 1
    IniWrite($NowFile,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($NowFile2,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($NowFile3,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($NowFile4,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))

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

    IniWrite($NowFile,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($NowFile,"Other","TreeItems",$Entrys)
    IniWrite($NowFile,"Other","EarNumber",GUICtrlRead($CowEarNumber))
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    Else
    MsgBox(16,"Achtung!","Die angegebene Datei existiert nicht mehr!",$Form1,$Form1)
    $NowFile = ""
    EndIf
    EndIf
    EndFunc

    [/autoit]
  • @Gothic30381: könntest du den Quellcode auch in einen Spoiler schreiben?
    Tipp: Schreib das Skript so (z.B. mit Case), dass sich das aktuelle TabItem als Variable abspeichert:

    Spoiler anzeigen
    [autoit]

    $Index = GUICtrlRead($hwnd)
    ; nach abspeichern dann
    _GUICtrlTab_SetCurSel($hwnd, $Index)

    [/autoit]
  • Das ist ja das Problem.Wenn ich es mit Case $Tab1 mache,dann ist ja schon die Tab gewählt und wenn ich es dann mit guictrlread mache,dann liest er ja die momentane tab aus

  • Wieso erstellst du die Funktionen mitten im Script? Das macht das ganze nur unübersichtlich ;).
    So müsste es funktionieren:

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiTab.au3>
    #include <GuiListView.au3>

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

    Global $Title = "Cow Worker"
    Global $MainCostTogehterGlobal = "-"
    Global $Entrys = 1
    Global $Klick = 0
    Global $NowFile
    Global $NowFile2
    Global $NowFile3
    Global $NowFile4
    Global $KorrektLoad
    Global $LoadMode
    Global $WithnoCWC = False
    Global $TabMode

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

    Global $EncryptCowName
    Global $EncryptCowEarNumber
    Global $EncryptDate
    Global $EncryptMedikament
    Global $EncryptDosierung
    Global $EncryptCost

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

    Global $DecryptCowName
    Global $DecryptEarNumber
    Global $DecryptDate
    Global $DecryptMedikament
    Global $DecryptDosierung
    Global $DecryptCost

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

    $FavoriteListRead = FileRead(@ScriptDir & "\FavoritList.ini")
    If @error Then
    FileWrite(@ScriptDir & "\FavoritList.ini","Medikament")
    EndIf
    If FileReadLine(@ScriptDir & "\FavoritList.ini",1) = "" Then
    If FileExists(@ScriptDir & "\FavoritList.ini") Then
    FileDelete(@ScriptDir & "\FavoritList.ini")
    FileWrite(@ScriptDir & "\FavoritList.ini","Medikament")
    Else
    FileWrite(@ScriptDir & "\FavoritList.ini","Medikament")
    EndIf
    EndIf
    _OptionsCheck()

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

    $FavoriteListRead = ""
    $FavoriteListRead = FileRead(@ScriptDir & "\FavoritList.ini")

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

    #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Scripts\Cow worker\Cow_Worker_Main_Window.kxf
    $Form1 = GUICreate($Title, 499, 542, -1, -1)
    GUICtrlCreateLabel("Kuh name:", 8, 48, 105, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $CowName = GUICtrlCreateInput("", 8, 80, 161, 21)
    GUICtrlCreateLabel("Ohrmarkennummer:", 8, 112, 191, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $CowEarNumber = GUICtrlCreateInput("", 8, 144, 161, 21)
    GUICtrlCreateLabel("Datum:", 8, 176, 69, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Date = GUICtrlCreateInput("", 8, 208, 161, 21)
    GUICtrlCreateLabel("Medikament:", 8, 240, 123, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Medikament = GUICtrlCreateInput("", 8, 272, 161, 21)
    GUICtrlCreateLabel("Dosierung:", 8, 304, 106, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Dosierung = GUICtrlCreateInput("", 8, 336, 161, 21)
    $Combo1 = GUICtrlCreateCombo("", 328, 272, 145, 25)
    $ToMedikamentFavorite = GUICtrlCreateButton("Medikament zur Favoritenliste", 176, 272, 145, 25, $WS_GROUP)
    GUICtrlCreateLabel("Kosten:", 8, 368, 74, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Cost = GUICtrlCreateInput("", 8, 400, 161, 21)
    $MainCost = GUICtrlCreateLabel("Gesamtkosten: " & $MainCostTogehterGlobal, 176, 440, 3941, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $SaveCow = GUICtrlCreateButton("Kuh und Eintrag speichern", 72, 504, 129, 25, $WS_GROUP)
    $LoadCow = GUICtrlCreateButton("Eine Kuh laden", 200, 504, 129, 25, $WS_GROUP)
    $NewEntry = GUICtrlCreateButton("Eintrag erstellen", 328, 504, 113, 25, $WS_GROUP)
    $GenerateDate = GUICtrlCreateButton("Heutiges Datum eintragen", 176, 208, 137, 25, $WS_GROUP)
    $Tab1 = GUICtrlCreateTab(0, 16, 489, 25)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    GUICtrlCreateTabItem("Eintrag1")
    $List1 = GUICtrlCreateList("", 240, 56, 241, 149)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    GUICtrlSetData($Combo1,$FavoriteListRead)
    GUICtrlSetData($List1,"Eintrag1")
    ;HotKeySet("{w}","_LoadEntrys")
    $iTabOldTmp = 0
    If $TabMode = True Then
    GUICtrlSetState($List1,$GUI_HIDE)
    Else
    GUICtrlSetState($Tab1,$GUI_HIDE)
    EndIf
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Combo1
    If GUICtrlRead($Combo1) = "Medikament" Or GUICtrlRead($Combo1) = "|Medikament" Then
    MsgBox(16,"Achtung!","Das angegebene Medikament ist kein Medikament!",$Form1,$Form1)
    Else
    $Ask1 = MsgBox(68,"Verwenden?","Möchten sie " & GUICtrlRead($Combo1) & " als Medikament verwenden?",$Form1,$Form1)
    If $Ask1 = 6 Then
    GUICtrlSetData($Medikament,GUICtrlRead($Combo1))
    EndIf
    EndIf
    Case $ToMedikamentFavorite
    If GUICtrlRead($Medikament) = "" Then
    MsgBox(16,"Achtung!","Bitte geben sie ein Medikament ein!",$Form1,$Form1)
    Else
    $Ask2 = MsgBox(68,"Verwenden?","Möchten sie " & GUICtrlRead($Medikament) & " hinzufügen?",$Form1,$Form1)
    If $Ask2 = 6 Then
    If StringInStr($FavoriteListRead,GUICtrlRead($Medikament)) Then
    MsgBox(16,"Achtung!","Dieses Medikament exestiert bereits!",$Form1,$Form1)
    Else
    FileWrite(@ScriptDir & "\FavoritList.ini",@CRLF & "|" & GUICtrlRead($Medikament))
    GUICtrlSetData($Combo1,"")
    GUICtrlSetData($Combo1,FileRead(@ScriptDir & "\FavoritList.ini"))
    MsgBox(64,"Info","Medikament " & GUICtrlRead($Medikament) & " hinzugefügt!",$Form1,$Form1)
    EndIf
    EndIf
    EndIf
    Case $Tab1
    If $NowFile = "" Then
    MsgBox(16,"Achtung!","Bitte speichern sie bevor sie einen Eintrag wählen!",$Form1,$Form1)
    Else
    $Ask4 = MsgBox(68,"Speichern?","Möchten sie speichern bevor sie den Eintrag wechseln?",$Form1,$Form1)
    If $Ask4 = 6 Then
    _GUICtrlTab_SetCurSel($Tab1, $iTabOldTmp)
    EndIf
    EndIf
    $iTabOldTmp = _GUICtrlTab_GetCurSel($Tab1)
    ;_LoadDataforEntrys()
    Case $List1
    If $NowFile = "" Then
    MsgBox(16,"Achtung!","Bitte speichern sie bevor sie einen Eintrag wählen!",$Form1,$Form1)
    Else
    $Ask3 = MsgBox(68,"Speichern?","Möchten sie speichern bevor sie einen einen anderen Eintrag wählen?",$Form1,$Form1)
    If $Ask3 = 7 Then
    _ContinueSave()
    EndIf
    EndIf
    _LoadDataforEntrys2()

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

    Case $SaveCow
    If GUICtrlRead($CowName) = "" Then
    MsgBox(16,"Achtung!","Bitte geben sie einen Kuhnamen an!",$Form1,$Form1)
    Else
    If GUICtrlRead($CowEarNumber) = "" Then
    GUICtrlSetData($CowEarNumber,"-")
    EndIf
    If GUICtrlRead($Date) = "" Then
    GUICtrlSetData($Date,"-")
    EndIf
    If GUICtrlRead($Medikament) = "" Then
    GUICtrlSetData($Medikament,"-")
    EndIf
    If GUICtrlRead($Dosierung) = "" Then
    GUICtrlSetData($Dosierung,"-")
    EndIf
    If GUICtrlRead($Cost) = "" Then
    GUICtrlSetData($Cost,"-")
    EndIf
    If $TabMode = True Then
    _ContinueSave()
    Else
    _ContinueSave2()
    EndIf
    EndIf
    Case $LoadCow
    If $TabMode = True Then
    _LoadCow1()
    Else
    _LoadCow2()
    EndIf
    Case $NewEntry
    If $NowFile = "" Then
    MsgBox(16,"Achtung!","Bitte speichern sie bevor sie einen neuen Eintrag erstellen!",$Form1,$Form1)
    Else
    $Entrys += 1
    If $TabMode = True Then
    GUICtrlCreateTabItem("Eintrag" & $Entrys)
    Else
    GUICtrlSetData($List1,"Eintrag" & $Entrys)
    EndIf
    EndIf
    Case $GenerateDate
    GUICtrlSetData($Date,@MDAY & "." & @MON & "." & @YEAR & " " & @HOUR & ":" & @MIN)

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

    EndSwitch
    WEnd

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

    Func _LoadEntrys()
    SplashTextOn("","Bitte warten...")
    ;GUISetState(@SW_MAXIMIZE,$Form1)
    For $i = 0 To $Entrys
    SplashTextOn("","Bitte warten...")
    $Klick += 1
    ;MouseClick("left",517, 46,1)
    ;Hier werden die Tabs ausgewählt?
    ;SplashOff()
    ;MsgBox(64,"",GUICtrlRead($Medikament))
    Next
    $Klick = 0
    ;GUISetState(@SW_RESTORE,$Form1)
    SplashOff()
    EndFunc

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

    Func _ResetLabels()
    GUICtrlSetData($CowName,"")
    GUICtrlSetData($CowEarNumber,"")
    GUICtrlSetData($Date,"")
    GUICtrlSetData($Medikament,"")
    GUICtrlSetData($Dosierung,"")
    GUICtrlSetData($Cost,"")
    EndFunc

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

    Func _LoadDataforEntrys()
    $NowTab = GUICtrlRead($Tab1)
    $NowTab += 1
    $ReadDataforEntrys1 = IniRead($NowFile,"Eintrag" & $NowTab,"Date","")
    $ReadDataforEntrys2 = IniRead($NowFile,"Eintrag" & $NowTab,"Medikament","")
    $ReadDataforEntrys3 = IniRead($NowFile,"Eintrag" & $NowTab,"Dosierung","")
    $ReadDataforEntrys4 = IniRead($NowFile,"Eintrag" & $NowTab,"Cost","")
    GUICtrlSetData($Date,$ReadDataforEntrys1)
    GUICtrlSetData($Medikament,$ReadDataforEntrys2)
    GUICtrlSetData($Dosierung,$ReadDataforEntrys3)
    GUICtrlSetData($Cost,$ReadDataforEntrys4)
    If $LoadMode = True Then
    If $ReadDataforEntrys1 = "" Or $ReadDataforEntrys2 = "" Or $ReadDataforEntrys3 = "" Or $ReadDataforEntrys4 = "" Then
    SplashOff()
    MsgBox(48,"Warnung!","Einige Daten für Eintrag" & $NowTab & " konnten nicht geladen werden!",$Form1,$Form1)
    $KorrektLoad = False
    Else
    $KorrektLoad = True
    EndIf
    EndIf
    EndFunc

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

    Func _LoadDataforEntrys2()
    $NowTab = GUICtrlRead($List1)
    $ReadDataforEntrys1 = IniRead($NowFile,"Eintrag" & $NowTab,"Date","")
    $ReadDataforEntrys2 = IniRead($NowFile,"Eintrag" & $NowTab,"Medikament","")
    $ReadDataforEntrys3 = IniRead($NowFile,"Eintrag" & $NowTab,"Dosierung","")
    $ReadDataforEntrys4 = IniRead($NowFile,"Eintrag" & $NowTab,"Cost","")
    GUICtrlSetData($Date,$ReadDataforEntrys1)
    GUICtrlSetData($Medikament,$ReadDataforEntrys2)
    GUICtrlSetData($Dosierung,$ReadDataforEntrys3)
    GUICtrlSetData($Cost,$ReadDataforEntrys4)
    If $LoadMode = True Then
    If $ReadDataforEntrys1 = "" Or $ReadDataforEntrys2 = "" Or $ReadDataforEntrys3 = "" Or $ReadDataforEntrys4 = "" Then
    SplashOff()
    MsgBox(48,"Warnung!","Einige Daten für Eintrag" & $NowTab & " konnten nicht geladen werden!",$Form1,$Form1)
    $KorrektLoad = False
    Else
    $KorrektLoad = True
    EndIf
    EndIf
    EndFunc

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

    Func _ContinueSave()
    If $NowFile = "" Then
    $Path = FileSaveDialog("Speichern",@DesktopDir,"Cow Worker Cow Datei(*.cwc)",16,"",$Form1)
    If @error Then
    Else
    If FileExists($Path) Then
    FileDelete($Path)
    $WithnoCWC = True
    EndIf
    SplashTextOn("","Speichern läuft...")
    $NowTab = ""
    $NowTab = GUICtrlRead($Tab1)
    $NowTab += 1
    $NowFile = $Path
    If $WithnoCWC = True Then
    IniWrite($Path,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path,"Other","TreeItems",$Entrys)
    IniWrite($Path,"Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    Else
    IniWrite($Path & ".cwc","Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path & ".cwc","Other","TreeItems",$Entrys)
    IniWrite($Path & ".cwc","Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    EndIf
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    EndIf
    Else
    If FileExists($NowFile) Then
    SplashTextOn("","Speichern läuft...")
    $NowTab = GUICtrlRead($Tab1)
    $NowTab += 1
    IniWrite($NowFile,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($NowFile2,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($NowFile3,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($NowFile4,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))

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

    IniWrite($NowFile,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($NowFile,"Other","TreeItems",$Entrys)
    IniWrite($NowFile,"Other","EarNumber",GUICtrlRead($CowEarNumber))
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    Else
    MsgBox(16,"Achtung!","Die angegebene Datei existiert nicht mehr!",$Form1,$Form1)
    $NowFile = ""
    EndIf
    EndIf
    EndFunc

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

    Func _OptionsCheck()
    If FileExists(@ScriptDir & "\Options.ini") Then
    If IniRead(@ScriptDir & "\Options.ini","Data","TabMode","") = "True" Then
    $TabMode = True
    Else
    $TabMode = False
    EndIf
    Else
    IniWrite(@ScriptDir & "\Options.ini","Data","TabMode","True")
    _OptionsCheck()
    EndIf
    EndFunc

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

    Func _ContinueSave2()
    If $NowFile = "" Then
    $Path = FileSaveDialog("Speichern",@DesktopDir,"Cow Worker Cow Datei(*.cwc)",16,"",$Form1)
    If @error Then
    Else
    If FileExists($Path) Then
    FileDelete($Path)
    $WithnoCWC = True
    EndIf
    SplashTextOn("","Speichern läuft...")
    $NowTab = ""
    $NowTab = GUICtrlRead($List1)
    $NowTab += 1
    $NowFile = $Path
    If $WithnoCWC = True Then
    IniWrite($Path,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path,"Other","TreeItems",$Entrys)
    IniWrite($Path,"Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    Else
    IniWrite($Path & ".cwc","Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path & ".cwc","Other","TreeItems",$Entrys)
    IniWrite($Path & ".cwc","Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    EndIf
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    EndIf
    Else
    If FileExists($NowFile) Then
    SplashTextOn("","Speichern läuft...")
    $NowTab = GUICtrlRead($List1)
    $NowTab += 1
    IniWrite($NowFile,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($NowFile2,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($NowFile3,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($NowFile4,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))

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

    IniWrite($NowFile,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($NowFile,"Other","TreeItems",$Entrys)
    IniWrite($NowFile,"Other","EarNumber",GUICtrlRead($CowEarNumber))
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    Else
    MsgBox(16,"Achtung!","Die angegebene Datei existiert nicht mehr!",$Form1,$Form1)
    $NowFile = ""
    EndIf
    EndIf
    EndFunc

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

    Func _LoadCow1()
    $LoadPath = FileOpenDialog("Eine Kuh laden",@DesktopDir,"Cow Worker Datei(*.cwc)",1,"",$Form1)
    If @error Then
    Else
    GUISetState(@SW_DISABLE,$Form1)
    $TreeItemsRead = IniRead($LoadPath,"Other","TreeItems","")
    If @error Then
    MsgBox(16,"Achtung!","Die Einträge konnten nicht gelesen werden!",$Form1,$Form1)
    GUISetState(@SW_ENABLE,$Form1)
    Else
    SplashTextOn("","Einträge werden entfernt...")
    Sleep(500)
    $LoadMode = True
    $Entrys = 0
    _GUICtrlTab_DeleteAllItems($Tab1)
    _ResetLabels()
    Sleep(500)
    SplashTextOn("","Lade Einträge von Datei " & $LoadPath & ".Dies kann je nach größe der Datei eine Weile dauern...")
    For $i = 1 To $TreeItemsRead
    $Entrys += 1
    GUICtrlCreateTabItem("Eintrag" & $Entrys)
    Next
    GUICtrlSetData($CowName,IniRead($LoadPath,"Other","CowName",""))
    GUICtrlSetData($CowEarNumber,IniRead($LoadPath,"Other","EarNumber",""))
    $NowFile = $LoadPath
    $NowFile2 = $LoadPath
    $NowFile3 = $LoadPath
    $NowFile4 = $LoadPath
    _LoadDataforEntrys()
    SplashOff()
    GUISetState(@SW_ENABLE,$Form1)
    If $KorrektLoad = True Then
    MsgBox(64,"Hinweiß","Die Kuh wurde mit " & IniRead($LoadPath,"Other","TreeItems","") & " Einträge erfolgreich geladen!",$Form1,$Form1)
    Else
    MsgBox(64,"Hinweiß","Die Kuh wurde geladen.Jedoch konnten einige Angaben für Eintrag1 nicht geladen werden.Geladene Tabs:" & IniRead($LoadPath,"Other","TreeItems",""),$Form1,$Form1)
    EndIf
    $LoadMode = False
    EndIf
    EndIf
    EndFunc

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

    Func _LoadCow2()
    $LoadPath = FileOpenDialog("Eine Kuh laden",@DesktopDir,"Cow Worker Datei(*.cwc)",1,"",$Form1)
    If @error Then
    Else
    GUISetState(@SW_DISABLE,$Form1)
    $TreeItemsRead = IniRead($LoadPath,"Other","TreeItems","")
    If @error Then
    MsgBox(16,"Achtung!","Die Einträge konnten nicht gelesen werden!",$Form1,$Form1)
    GUISetState(@SW_ENABLE,$Form1)
    Else
    SplashTextOn("","Einträge werden entfernt...")
    Sleep(500)
    $LoadMode = True
    $Entrys = 0
    GUICtrlSetData($List1,"")
    _ResetLabels()
    Sleep(500)
    SplashTextOn("","Lade Einträge von Datei " & $LoadPath & ".Dies kann je nach größe der Datei eine Weile dauern...")
    For $i = 1 To $TreeItemsRead
    $Entrys += 1
    GUICtrlSetData($List1,"Eintrag" & $Entrys)
    Next
    GUICtrlSetData($CowName,IniRead($LoadPath,"Other","CowName",""))
    GUICtrlSetData($CowEarNumber,IniRead($LoadPath,"Other","EarNumber",""))
    $NowFile = $LoadPath
    $NowFile2 = $LoadPath
    $NowFile3 = $LoadPath
    $NowFile4 = $LoadPath
    _LoadDataforEntrys()
    SplashOff()
    GUISetState(@SW_ENABLE,$Form1)
    If $KorrektLoad = True Then
    MsgBox(64,"Hinweiß","Die Kuh wurde mit " & IniRead($LoadPath,"Other","TreeItems","") & " Einträge erfolgreich geladen!",$Form1,$Form1)
    Else
    MsgBox(64,"Hinweiß","Die Kuh wurde geladen.Jedoch konnten einige Angaben für Eintrag1 nicht geladen werden.Geladene Tabs:" & IniRead($LoadPath,"Other","TreeItems",""),$Form1,$Form1)
    EndIf
    $LoadMode = False
    EndIf
    EndIf
    EndFunc

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

    Func _SaveTab($ReadedTab)
    If $NowFile = "" Then
    $Path = FileSaveDialog("Speichern",@DesktopDir,"Cow Worker Cow Datei(*.cwc)",16,"",$Form1)
    If @error Then
    Else
    If FileExists($Path) Then
    FileDelete($Path)
    $WithnoCWC = True
    EndIf
    SplashTextOn("","Speichern läuft...")
    $NowTab = ""
    $NowTab = $ReadedTab
    $NowTab += 1
    $NowFile = $Path
    If $WithnoCWC = True Then
    IniWrite($Path,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path,"Other","TreeItems",$Entrys)
    IniWrite($Path,"Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    Else
    IniWrite($Path & ".cwc","Other","CowName",GUICtrlRead($CowName))
    IniWrite($Path & ".cwc","Other","TreeItems",$Entrys)
    IniWrite($Path & ".cwc","Other","EarNumber",GUICtrlRead($CowEarNumber))

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

    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($Path & ".cwc","Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))
    EndIf
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    EndIf
    Else
    If FileExists($NowFile) Then
    SplashTextOn("","Speichern läuft...")
    $NowTab = $ReadedTab
    $NowTab += 1
    IniWrite($NowFile,"Eintrag" & $NowTab,"Date",GUICtrlRead($Date))
    IniWrite($NowFile2,"Eintrag" & $NowTab,"Medikament",GUICtrlRead($Medikament))
    IniWrite($NowFile3,"Eintrag" & $NowTab,"Dosierung",GUICtrlRead($Dosierung))
    IniWrite($NowFile4,"Eintrag" & $NowTab,"Cost",GUICtrlRead($Cost))

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

    IniWrite($NowFile,"Other","CowName",GUICtrlRead($CowName))
    IniWrite($NowFile,"Other","TreeItems",$Entrys)
    IniWrite($NowFile,"Other","EarNumber",GUICtrlRead($CowEarNumber))
    SplashOff()
    MsgBox(64,"Hinweiß","Der Eintrag sowie die Kuh wurden erfolgreich gespeichert!",$Form1,$Form1)
    Else
    MsgBox(16,"Achtung!","Die angegebene Datei existiert nicht mehr!",$Form1,$Form1)
    $NowFile = ""
    EndIf
    EndIf
    EndFunc

    [/autoit]