Kleine deppenfrage wegen funktionen

  • Hi,
    Ich wollte kurz nen script erstellen das wenn man auf den button oder auf y drückt ein1 hochzählt cund dann das label so setzt. So mein bisheriger code.

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $count = 0
    Func counter()
    $count = $count+1
    EndFunc

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("GalaxyGate Zähler", 310, 190, 192, 124)
    $Label1 = GUICtrlCreateLabel($count, 32, 40, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 32, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 88, 104, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter

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

    EndSwitch
    WEnd

    [/autoit]


    ich weiß jetzt grad net wo der fehler ist.

  • Hi,

    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Global $count = 0 ; geändert

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("GalaxyGate Zähler", 310, 190, 192, 124)
    $Label1 = GUICtrlCreateLabel($count, 32, 40, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 32, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 88, 104, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter () ; geändert Funktionsaufruf
    GUICtrlSetData ($Label1, $count) ; eingefügt
    EndSwitch
    WEnd

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

    Func counter()
    $count = $count+1
    EndFunc

    [/autoit]

    ;-))
    Stefan

  • Oh jetzt ist aber wieder ein Fehler das und zwar ich habe gesagt wenn er bei 80 ankommt soll eine msg boc kommen aber wenn man gleich einmal also das erste mal drückt kommt das schon:
    Der Code:

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Global $count = 0

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do.kxf
    $Form1 = GUICreate("GalaxyGate Zähler", 460, 317, 192, 124)
    $MenuItem1 = GUICtrlCreateMenu("Datei")
    $Label1 = GUICtrlCreateLabel($count, 40, 96, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 112, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 208, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func counter()
    Switch $count
    Case $count=80
    MsgBox(64,"Welle geschafft", "Du hast die Welle geschafft")
    GUICtrlSetData($Label1,$count=0)

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

    EndSwitch
    $count = $count+1
    GUICtrlSetData ($Label1, $count)
    EndFunc

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

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

    [/autoit]
  • Hi,

    Änderung von Funktion:

    [autoit]

    Func counter()
    If $count=80 Then
    MsgBox(64,"Welle geschafft", "Du hast die Welle geschafft")
    $count = 0
    Else
    $count = $count+1
    EndIf
    GUICtrlSetData ($Label1, $count)
    EndFunc

    [/autoit]

    ;-))
    Stefan

  • Hey ich habe jetzt 2 forms erstellt und ich weiß einfach net warum das 2 sich nicht öffnet wenn man auf einstellungen geht!
    Code:

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Global $count = 0

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do.kxf
    $Form1 = GUICreate("GalaxyGate Zähler", 460, 317, 192, 124)
    $Menu= GUICtrlCreateMenu("Datei")
    $Menuitem1= GUICtrlCreateMenuItem("Einstellungen",$Menu)
    $Menuitem2= GUICtrlCreateMenuItem("Speichern",$Menu)
    $Menuitem1= GUICtrlCreateMenuItem("Info",$Menu)
    $Label1 = GUICtrlCreateLabel($count, 40, 96, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 112, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 208, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do2.kxf
    $Form2 = GUICreate("Einstellungen", 358, 184, 193, 125)
    $Label3 = GUICtrlCreateLabel("Gate", 24, 32, 36, 17)
    $Label4 = GUICtrlCreateLabel("Welle", 24, 72, 36, 17)
    $Combo1 = GUICtrlCreateCombo("Alpha", 120, 32, 145, 25)
    $Combo2 = GUICtrlCreateCombo("Combo2", 120, 72, 145, 25)
    $Button3 = GUICtrlCreateButton("Speichern", 128, 128, 75, 25, 0)
    GUISetState(@SW_Hide)
    #EndRegion ### END Koda GUI section ###
    ;Implementierung der Combo Boxen
    GUICtrlSetData($Combo1,"Beta|Gamma|Delta")

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

    Func counter()
    If $count=80 Then
    MsgBox(64,"Welle geschafft", "Du hast die Welle geschafft")
    $count = 0
    Else
    $count = $count+1
    EndIf
    GUICtrlSetData ($Label1, $count)
    EndFunc

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

    Func reset()
    $count=0
    GUICtrlSetData($Label1,$count)
    EndFunc

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter()
    Case $Button2
    reset()
    Case $Menuitem1
    $Form2= GUISetState(@SW_Show)

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

    EndSwitch
    WEnd

    [/autoit]

    Einmal editiert, zuletzt von franjob (2. November 2009 um 15:51)

  • Hi,

    mit F1 bekommst Du auch ne gute Hilfe:

    Siehe Funktion GUISetState ()

    GUISetState(@SW_Show, $Form2)

    ;-))
    Stefan

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Global $count = 0

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do.kxf
    $Form1 = GUICreate("GalaxyGate Zähler", 460, 317, 192, 124)
    $Menu= GUICtrlCreateMenu("Datei")
    $Menuitem1= GUICtrlCreateMenuItem("Einstellungen",$Menu)
    $Menuitem2= GUICtrlCreateMenuItem("Speichern",$Menu)
    $Menuitem3= GUICtrlCreateMenuItem("Info",$Menu)
    $Label1 = GUICtrlCreateLabel($count, 40, 96, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 112, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 208, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do2.kxf
    $Form2 = GUICreate("Einstellungen", 358, 184, 193, 125)
    $Label3 = GUICtrlCreateLabel("Gate", 24, 32, 36, 17)
    $Label4 = GUICtrlCreateLabel("Welle", 24, 72, 36, 17)
    $Combo1 = GUICtrlCreateCombo("Alpha", 120, 32, 145, 25)
    $Combo2 = GUICtrlCreateCombo("Combo2", 120, 72, 145, 25)
    $Button3 = GUICtrlCreateButton("Speichern", 128, 128, 75, 25, 0)
    GUISetState(@SW_Hide)
    #EndRegion ### END Koda GUI section ###
    ;Implementierung der Combo Boxen
    GUICtrlSetData($Combo1,"Beta|Gamma|Delta")

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

    Func counter()
    If $count=80 Then
    MsgBox(64,"Welle geschafft", "Du hast die Welle geschafft")
    $count = 0
    Else
    $count = $count+1
    EndIf
    GUICtrlSetData ($Label1, $count)
    EndFunc

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

    Func reset()
    $count=0
    GUICtrlSetData($Label1,$count)
    EndFunc

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter()
    Case $Button2
    reset()
    Case $Menuitem1
    GUISetState(@SW_SHOW,$Form2)

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

    EndSwitch
    WEnd

    [/autoit]

    Du hattest auch $Menuitem1 doppelt belegt.

    Vorhin hattest du gefragt wie man ein Combo anhand einer Comboauswahl befüllen kann hier ist ein Beispiel:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    Global $Form1 = GUICreate("Form1", 451, 238, 192, 124)
    Global $Combo1 = GUICtrlCreateCombo("", 40, 16, 145, 25)
    GUICtrlSetData(-1, "|item1|item2|item3", "item3")
    Global $Combo2 = GUICtrlCreateCombo("", 40, 152, 145, 25)
    Global $Button1 = GUICtrlCreateButton("Ende", 328, 16, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE , $Button1
    Exit
    Case $Combo1
    $Auswahl = GUICtrlRead($Combo1)
    Switch $Auswahl
    Case "item1"
    GUICtrlSetData($Combo2, "|item1|item2|item3", "item3")
    Case "item2"
    GUICtrlSetData($Combo2, "|item4|item5|item6", "item6")
    Case "item3"
    GUICtrlSetData($Combo2, "|item7|item8|item9", "item9")
    EndSwitch
    Case $Combo2
    MsgBox(0,"Info","Es wurde in Combo 2 "&GUICtrlRead($Combo2)& " ausgewählt.")
    EndSwitch
    WEnd

    [/autoit]
  • aber wenn man jetzt das einstellungs fenster schließt schließst sich alles, es soll sich aber nur dasn einstellungs fenster schließen. ach ja und wie kann ich kann ich den default werd von der combo box bestimmen?

    Einmal editiert, zuletzt von franjob (2. November 2009 um 16:44)

    • Offizieller Beitrag

    Dafür gibt es die erweiterte Abfrage von GUIGetMsg.

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Global $count = 0

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do.kxf
    $Form1 = GUICreate("GalaxyGate Zähler", 460, 317, 192, 124)
    $Menu = GUICtrlCreateMenu("Datei")
    $Menuitem1 = GUICtrlCreateMenuItem("Einstellungen", $Menu)
    $Menuitem2 = GUICtrlCreateMenuItem("Speichern", $Menu)
    $Menuitem3 = GUICtrlCreateMenuItem("Info", $Menu)
    $Label1 = GUICtrlCreateLabel($count, 40, 96, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 112, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 208, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do2.kxf
    $Form2 = GUICreate("Einstellungen", 358, 184, 193, 125)
    $Label3 = GUICtrlCreateLabel("Gate", 24, 32, 36, 17)
    $Label4 = GUICtrlCreateLabel("Welle", 24, 72, 36, 17)
    $Combo1 = GUICtrlCreateCombo("Alpha", 120, 32, 145, 25)
    $Combo2 = GUICtrlCreateCombo("Combo2", 120, 72, 145, 25)
    $Button3 = GUICtrlCreateButton("Speichern", 128, 128, 75, 25, 0)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###
    ;Implementierung der Combo Boxen
    GUICtrlSetData($Combo1, "Beta|Gamma|Delta")

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

    Func counter()
    If $count = 80 Then
    MsgBox(64, "Welle geschafft", "Du hast die Welle geschafft")
    $count = 0
    Else
    $count = $count + 1
    EndIf
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>counter

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

    Func reset()
    $count = 0
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>reset

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter()
    Case $Button2
    reset()
    Case $Menuitem1
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]

    Steht aber alles auch in der Hilfe. ;)

  • [autoit]

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ; fragt den window handle ab (also von welcher GUI es kommt)
    Case $Form1
    Switch $nMsg[0] ;fragt das Ereignis ab.
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter()
    Case $Button2
    reset()
    Case $Menuitem1
    GUISetState(@SW_Show, $Form2)
    EndSwitch

    Case $Form2
    Switch $nMsg[0] ;fragt das Ereignis ab.
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    ;oder
    ;~ GUIDelete($Form2)
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]

    EDIT: Verdammt zu langsam...

  • Sorry aber jetzt klappts mit den Combo boxen iwie net mehr.
    Ka warum der Code:

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    Global $count = 0

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do.kxf
    $Form1 = GUICreate("GalaxyGate Zähler", 460, 317, 192, 124)
    $Menu = GUICtrlCreateMenu("Datei")
    $Menuitem1 = GUICtrlCreateMenuItem("Einstellungen", $Menu)
    $Menuitem2 = GUICtrlCreateMenuItem("Speichern", $Menu)
    $Menuitem3 = GUICtrlCreateMenuItem("Info", $Menu)
    $Label1 = GUICtrlCreateLabel($count, 40, 96, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 112, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 208, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do2.kxf
    $Form2 = GUICreate("Einstellungen", 358, 184, 193, 125)
    $Label3 = GUICtrlCreateLabel("Gate", 24, 32, 36, 17)
    $Label4 = GUICtrlCreateLabel("Welle", 24, 72, 36, 17)
    $Combo1 = GUICtrlCreateCombo("", 120, 32, 145, 25)
    $Combo2 = GUICtrlCreateCombo("", 120, 72, 145, 25)
    $Button3 = GUICtrlCreateButton("Speichern", 128, 128, 75, 25, 0)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###
    ;Implementierung der Combo Boxen
    GUICtrlSetData($Combo1, "Alpha|Beta|Gamma|Delta")

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

    Func counter()
    If $count = 80 Then
    MsgBox(64, "Welle geschafft", "Du hast die Welle geschafft")
    $count = 0
    Else
    $count = $count + 1
    EndIf
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>counter

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

    Func reset()
    $count = 0
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>reset

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter()
    Case $Button2
    reset()
    Case $Combo1
    $Auswahl = GUICtrlRead($Combo1)
    Switch $Auswahl
    Case "Alpha"
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    Case "Beta"
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    Case "Gamma"
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    Case "Delta"
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    EndSwitch
    Case $Menuitem1
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]
  • so vielleicht?

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Include <GuiComboBox.au3>

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

    Global $count = 0

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do.kxf
    $Form1 = GUICreate("GalaxyGate Zähler", 460, 317, 192, 124)
    $Menu = GUICtrlCreateMenu("Datei")
    $Menuitem1 = GUICtrlCreateMenuItem("Einstellungen", $Menu)
    $Menuitem2 = GUICtrlCreateMenuItem("Speichern", $Menu)
    $Menuitem3 = GUICtrlCreateMenuItem("Info", $Menu)
    $Label1 = GUICtrlCreateLabel($count, 40, 96, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 112, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 208, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do2.kxf
    $Form2 = GUICreate("Einstellungen", 358, 184, 193, 125)
    $Label3 = GUICtrlCreateLabel("Gate", 24, 32, 36, 17)
    $Label4 = GUICtrlCreateLabel("Welle", 24, 72, 36, 17)
    $Combo1 = GUICtrlCreateCombo("", 120, 32, 145, 25)
    $Combo2 = GUICtrlCreateCombo("", 120, 72, 145, 25)
    $Button3 = GUICtrlCreateButton("Speichern", 128, 128, 75, 25, 0)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###
    ;Implementierung der Combo Boxen
    GUICtrlSetData($Combo1, "Alpha|Beta|Gamma|Delta")

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

    Func counter()
    If $count = 80 Then
    MsgBox(64, "Welle geschafft", "Du hast die Welle geschafft")
    $count = 0
    Else
    $count = $count + 1
    EndIf
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>counter

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

    Func reset()
    $count = 0
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>reset

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter()
    Case $Button2
    reset()
    Case $Menuitem1
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    Case $Combo1
    $Auswahl = GUICtrlRead($Combo1)
    Switch $Auswahl
    Case "Alpha"
    _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    Case "Beta"
    _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    Case "Gamma"
    _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    Case "Delta"
    _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle")
    EndSwitch

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

    EndSwitch
    EndSwitch
    WEnd

    [/autoit]


    Das Event der Combobox passiert nämlich auf Form2 nicht auf Form1. und du solltest sie natürlich vorher löschen,
    (_GUICtrlComboBox_ResetContent($Combo2)) sonst siehts nach dem auswählen von 2 Sachen nacheinander (in combo 1) so aus:

    Spoiler anzeigen
  • Aber jetzt kommt der error:

    Code
    C:\Users\Franz\Desktop\do.au3(80,66) : ERROR: _GUICtrlComboBox_ResetContent(): undefined function.
                            	_GUICtrlComboBox_ResetContent($Combo2)
    • Offizieller Beitrag

    @franjob,
    ist es eigentlich zuviel verlangt, die Hilfe zu lesen?
    Aus der Hilfe von GuiCtrlSetData:

    Zitat

    Remarks

    For Combo or List control :
    If the "data" corresponds to an already existing entry it is set as the default.
    If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed.


    _GUICtrlComboBox_ResetContent() braucht man zum leeren einer Combobox nicht.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Include <GuiComboBox.au3>

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

    Global $count = 0

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do.kxf
    $Form1 = GUICreate("GalaxyGate Zähler", 460, 317, 192, 124)
    $Menu = GUICtrlCreateMenu("Datei")
    $Menuitem1 = GUICtrlCreateMenuItem("Einstellungen", $Menu)
    $Menuitem2 = GUICtrlCreateMenuItem("Speichern", $Menu)
    $Menuitem3 = GUICtrlCreateMenuItem("Info", $Menu)
    $Label1 = GUICtrlCreateLabel($count, 40, 96, 36, 17)
    $Button1 = GUICtrlCreateButton("Hochzählen", 176, 112, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Reset", 144, 208, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    #Region ### START Koda GUI section ### Form=C:\Users\Franz\Desktop\do2.kxf
    $Form2 = GUICreate("Einstellungen", 358, 184, 193, 125)
    $Label3 = GUICtrlCreateLabel("Gate", 24, 32, 36, 17)
    $Label4 = GUICtrlCreateLabel("Welle", 24, 72, 36, 17)
    $Combo1 = GUICtrlCreateCombo("", 120, 32, 145, 25)
    $Combo2 = GUICtrlCreateCombo("", 120, 72, 145, 25)
    $Button3 = GUICtrlCreateButton("Speichern", 128, 128, 75, 25, 0)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###
    ;Implementierung der Combo Boxen
    GUICtrlSetData($Combo1, "Alpha|Beta|Gamma|Delta")

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

    Func counter()
    If $count = 80 Then
    MsgBox(64, "Welle geschafft", "Du hast die Welle geschafft")
    $count = 0
    Else
    $count = $count + 1
    EndIf
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>counter

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

    Func reset()
    $count = 0
    GUICtrlSetData($Label1, $count)
    EndFunc ;==>reset

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    counter()
    Case $Button2
    reset()
    Case $Menuitem1
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    Case $Combo1
    $Auswahl = GUICtrlRead($Combo1)
    Switch $Auswahl
    Case "Alpha"
    ;~ _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"|1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle","1 Welle")
    Case "Beta"
    ;~ _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"|1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle","1 Welle")
    Case "Gamma"
    ;~ _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"|1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle","1 Welle")
    Case "Delta"
    ;~ _GUICtrlComboBox_ResetContent($Combo2)
    GUICtrlSetData($Combo2,"|1 Welle|2 Welle|3 Welle|4 Welle|5 Welle|6 Welle|7 Welle|8 Welle|9 Welle|10 Welle","1 Welle")
    EndSwitch

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

    EndSwitch
    EndSwitch
    WEnd

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


    Edit: Wenn du beim auswählen eines Eintrages in der Combo1 eine Auswahl in der Combo2 haben willst, mußt du auch angeben, welcher Eintrag selektiert werden soll. 3. Parameter von GUICtrlSetData. Steht auch in der Hilfe.