GUI - Button ?!

  • Also ich habe folgendes Problem, ich möchte einem Button zwei Funkctionen zuordnen,
    z.b. wenn man das erste mal den button drückt passiert function1, wenn man aber das zweite mal den button drückt passiert function2, beim dritten mal wieder function1

    Brauche eure Hilfe

    MfG Rakehunt

  • Meinst du es so? :

    Spoiler anzeigen
    [autoit]

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

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

    $Form1 = GUICreate("Form1", 186, 52, 193, 125)
    $Button1 = GUICtrlCreateButton("Button1", 8, 16, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Button2", 96, 16, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

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

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

    Case $Button1
    _msg1()

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

    Case $Button2
    _msg2()

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

    EndSwitch
    WEnd

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

    Func _msg1()
    MsgBox(0, "", "msg1")
    EndFunc ;==>_msg1

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

    Func _msg2()
    MsgBox(0, "", "msg2")
    EndFunc ;==>_msg2

    [/autoit]
  • na wohl eher so:

    Spoiler anzeigen
    [autoit]

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

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

    Global $var = 1

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

    $Form1 = GUICreate("Form1", 186, 52, 193, 125)
    $Button1 = GUICtrlCreateButton("Button1", 8, 16, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Button2", 96, 16, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

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

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

    Case $Button1
    Switch $var
    Case 1
    _msg1()
    $var += 1
    Case 2
    _msg2()
    $var += 1
    EndSwitch

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

    Case $Button2
    _msg2()

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

    EndSwitch
    WEnd

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

    Func _msg1()
    MsgBox(0, "", "msg1")
    EndFunc ;==>_msg1

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

    Func _msg2()
    MsgBox(0, "", "msg2")
    EndFunc ;==>_msg2

    [/autoit]

    MFG FireFlyer

    *Paradox ist, wenn man sich im Handumdrehen den Fuss bricht* :D

  • Also ich mein das ungefähr so:

    ButtonXXX lässt mein ersten mal wenn er gedrückt wird XXX ausgeben. Wenn er aber das 2. mal gedrückt wird soll er YYY ausgeben. Wenn er dann noch ein drittes Mal gedrückt wird soll er wieder XXX ausgeben, beim 4. mal wieder YYY usw...

  • ich denk mal so:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    Global $func_1 = True
    Global $func_2 = False

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

    GUICreate("My GUI")
    $button = GUICtrlCreateButton("Funktion", 50, 50, 80, 25)
    GUISetState (@SW_SHOW)

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

    While 1
    $msg = GUIGetMsg()

    Switch $msg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $button
    If $func_1 Then
    _Func_1()
    ElseIf $func_2 Then
    _Func_2()
    EndIf
    EndSwitch
    Wend

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

    Func _Func_1()
    $func_1 = False
    $func_2 = True
    MsgBox(0, "Info", "XXX")
    EndFunc

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

    Func _Func_2()
    $func_2 = False
    $func_1 = True
    MsgBox(0, "Info", "YYY")
    EndFunc

    [/autoit]
  • Oder wenn du es leichter haben willst so:

    Spoiler anzeigen
    [autoit]

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

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

    $Form1 = GUICreate("Form1", 186, 52, 193, 125)
    $Button1 = GUICtrlCreateButton("Button1", 8, 16, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

    $funktion1 = "ja"

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Button1

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

    If $funktion1 = "ja" Then
    _msg1()
    $funktion1 = "nein"

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

    ElseIf $funktion1 = "nein" Then
    _msg2()
    $funktion1 = "ja"
    EndIf

    EndSwitch
    WEnd

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

    Func _msg1()
    MsgBox(0, "", "msg1")
    EndFunc ;==>_msg1

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

    Func _msg2()
    MsgBox(0, "", "msg2")
    EndFunc ;==>_msg2

    [/autoit]

    :)

  • FirreFlyer hat doch fast schon die Lösung gepostet.
    Probiere nächstesmal bitte die Beispiele durch und versuche sie für dich umzuschreiben :D

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

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

    $var = 1

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

    $Form1 = GUICreate("Form1", 186, 52, 193, 125)
    $Button1 = GUICtrlCreateButton("Button1", 8, 16, 75, 25, 0)
    GUISetState(@SW_SHOW)

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

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

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

    Func _msg1()
    If $var = 1 Then
    MsgBox(0, "", "XXX")
    $var = 2
    Else
    MsgBox(0, "", "YYY")
    $var = 1
    EndIf
    EndFunc ;==>_msg1

    [/autoit]

    Edit: zu spät :whistling: