GUICtrlSetOnEvent

  • also wie oben geschrieben will ich damit was machen mit GUICtrlSetOnEvent.Wenn ich aber einmal auf einen button 1 raufklicke, kommt button 1.1 , 1.2 , 1.3 eine art auswahl menü, soweit sogut.nun will ich aber wenn ich wieder auf button 1 klicke das die buttons 1.1 , 1.2 , 1.3 wieder weg gehen hab aber kei plan wie oder einfach das gui refreschen oder so,weiss jemand rat?

    Einmal editiert, zuletzt von spaki (10. Juni 2009 um 00:32)

  • Hallo spaki,

    und wo ist das Skript, das du bis jetzt erstellt hast? Schau dir mal GUICtrlSetState ($GUI_SHOW / $GUI_HIDE) bzw. GUICtrlDelete an,


    mfg (Auto)Bert

  • #include <GUIConstants.au3>
    Opt("GUIOnEventMode",4)
    Global $buttons=2

    #Region ### START Koda GUI section ### Form=C:\Programme\AutoIt3\Neuer Ordner\Forms\Form1.kxf

    $Form1 = GUICreate("Form1", 633, 447, 193, 125)

    $Button_1 = GUICtrlCreateButton("spaki", 40, 56, 65, 33, 0)
    GUISetState(@SW_SHOW)

    #EndRegion ### END Koda GUI section ###

    GUISetOnEvent($GUI_EVENT_CLOSE,"_CLOSE")
    GUICtrlSetOnEvent($Button_1,"_add")
    While 1

    Sleep(100)
    WEnd
    Func _CLOSE()
    Exit
    EndFunc
    Func _add()
    $buttons=$buttons+0
    GUICtrlCreateButton("button1 " & $buttons,40,40+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK1")
    GUICtrlCreateButton("button2 " & $buttons,40,80+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK2")
    GUICtrlCreateButton("button3 " & $buttons,40,120+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK3")
    GUICtrlCreateButton("button4 " & $buttons,40,160+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK4")


    EndFunc
    Func _CLICK1()
    GUICtrlCreateButton(" 1 " & $buttons,120,40+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK1")
    GUICtrlCreateButton(" 2 " & $buttons,120,80+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK2")
    GUICtrlCreateButton(" 3 " & $buttons,120,120+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK3")
    GUICtrlCreateButton(" 4 " & $buttons,120,160+$buttons*40,65,33)
    EndFunc

    Func _CLICK2()
    Run ("notepad")
    EndFunc

    Func _CLICK3()
    Run ("notepad")
    EndFunc

    Func _CLICK4()
    Run ("notepad")
    EndFunc


    und noch ne frage wenn ich das gui öffner stehen ganz am ende hinter jedem button die gleichen zahlen ne 2 glaub ich wie gehen diese weg

    • Offizieller Beitrag

    Mach es so :

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    Opt("GUIOnEventMode",4)
    Global $buttons=2

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

    #Region ### START Koda GUI section ### Form=C:\Programme\AutoIt3\Neuer Ordner\Forms\Form1.kxf

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

    $Form1 = GUICreate("Form1", 633, 447, 193, 125)

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

    $Button_1 = GUICtrlCreateButton("spaki", 40, 56, 65, 33, 0)
    GUISetState(@SW_SHOW)

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

    #EndRegion ### END Koda GUI section ###

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

    GUISetOnEvent($GUI_EVENT_CLOSE,"_CLOSE")
    GUICtrlSetOnEvent($Button_1,"_add")
    While 1

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

    Sleep(100)
    WEnd
    Func _CLOSE()
    Exit
    EndFunc
    Func _add()
    GUICtrlCreateButton("button1 " ,40,40+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK1")
    GUICtrlCreateButton("button2 " ,40,80+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK2")
    GUICtrlCreateButton("button3 " ,40,120+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK3")
    GUICtrlCreateButton("button4 " ,40,160+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK4")

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

    EndFunc
    Func _CLICK1()
    GUICtrlCreateButton(" 1 " ,120,40+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK1")
    GUICtrlCreateButton(" 2 " ,120,80+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK2")
    GUICtrlCreateButton(" 3 " ,120,120+$buttons*40,65,33)
    GUICtrlSetOnEvent(-1,"_CLICK3")
    GUICtrlCreateButton(" 4 " ,120,160+$buttons*40,65,33)
    EndFunc

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

    Func _CLICK2()
    Run ("notepad")
    EndFunc

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

    Func _CLICK3()
    Run ("notepad")
    EndFunc

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

    Func _CLICK4()
    Run ("notepad")
    EndFunc

    [/autoit]


    Mir ist sowieso nicht ganz klar, was du mit der Variable $buttons willst .

    Edit : Hier mal ein Beispiel wie du es in Post 1 haben wolltest :

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    Opt("GUIOnEventMode", 4)
    Global $hButton1, $hButton2, $hButton3, $hButton4
    Global $hButton1_1, $hButton1_2, $hButton1_3, $hButton1_4
    Global $bMoreButtons = False
    #Region ### START Koda GUI section ### Form=C:\Programme\AutoIt3\Neuer Ordner\Forms\Form1.kxf

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

    $Form1 = GUICreate("Form1", 633, 447, 193, 125)

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

    $Button_1 = GUICtrlCreateButton("spaki", 40, 56, 65, 33, 0)
    GUISetState(@SW_SHOW)

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

    #EndRegion ### END Koda GUI section ###

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSE")
    GUICtrlSetOnEvent($Button_1, "_add")
    While 1

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

    Sleep(100)
    WEnd
    Func _CLOSE()
    Exit
    EndFunc ;==>_CLOSE
    Func _add()
    $hButton1 = GUICtrlCreateButton("Mehr Buttons ", 40, 120, 75, 33)
    GUICtrlSetOnEvent(-1, "_CLICK1")
    $hButton2 = GUICtrlCreateButton("button2 ", 40, 160, 75, 33)
    GUICtrlSetOnEvent(-1, "_CLICK2")
    $hButton3 = GUICtrlCreateButton("button3 ", 40, 200, 75, 33)
    GUICtrlSetOnEvent(-1, "_CLICK3")
    $hButton4 = GUICtrlCreateButton("button4 ", 40, 240, 75, 33)
    GUICtrlSetOnEvent(-1, "_CLICK4")

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

    EndFunc ;==>_add
    Func _CLICK1()
    $bMoreButtons = Not $bMoreButtons
    If $bMoreButtons = True Then
    $hButton1_1 = GUICtrlCreateButton(" 1 ", 130, 120, 65, 33)
    GUICtrlSetOnEvent(-1, "_CLICK1")
    $hButton1_2 = GUICtrlCreateButton(" 2 ", 130, 160, 65, 33)
    GUICtrlSetOnEvent(-1, "_CLICK2")
    $hButton1_3 = GUICtrlCreateButton(" 3 ", 130, 200, 65, 33)
    GUICtrlSetOnEvent(-1, "_CLICK3")
    $hButton1_4 = GUICtrlCreateButton(" 4 ", 130, 240, 65, 33)
    GUICtrlSetData($hButton1, "Weniger Buttons")
    Else
    GUICtrlDelete($hButton1_1)
    GUICtrlDelete($hButton1_2)
    GUICtrlDelete($hButton1_3)
    GUICtrlDelete($hButton1_4)
    GUICtrlSetData($hButton1, "Mehr Buttons")
    EndIf
    EndFunc ;==>_CLICK1

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

    Func _CLICK2()
    Run("notepad")
    EndFunc ;==>_CLICK2

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

    Func _CLICK3()
    Run("notepad")
    EndFunc ;==>_CLICK3

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

    Func _CLICK4()
    Run("notepad")
    EndFunc ;==>_CLICK4

    [/autoit]