Hilfe mit Funktion von Buttons und ihrer Zuweisung

  • Hallo liebe community,

    ich habe mich nun doch einmal hier bei euch angemeldet da ich eure hilfe benötige. ich habe erst neu angefangen mit autoit skripte zu schreiben und ich bin auch schon meines erachtens nach mit hilfe von google, autoit forum und der autoit datenbank recht weit gekommen.

    nun habe ich ein neues kleines programmchen mir vorgenommen wo ich allerdings nicht weiterkomme was wohl einfach daran liegt das ich einen falschen ansatz habe.

    ich hoffe ihr könnt mir helfen:

    aus übersichtlichen gründen habe ich eine abgespeckte version von meinem skript gemacht die als bsp. für mein problem gehandhabt werden soll. nun das programm soll folgendes tun:

    3x buttons + 3x inputboxes --> buttons werden benannt und egal welchen button ich drücke der name des button wird in inpoutbox 1 geschrieben. danach benennen sich die buttons um und der nächste klick egal auf welchen button soll bewirken das der name des geklickten button in inputbox 2 geschrieben wird. und dann noch ein weiteres mal ...

    hier das bsp. skript:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    ;variablen deklaration
    ;dies soll of den buttons als 1. stehen
    $text001 = ("001")
    $text002 = ("002")
    $text003 = ("003")
    ;dies als 2.
    $text010 = ("010")
    $text020 = ("020")
    $text030 = ("030")
    ;dies als 3.
    $text100 = ("100")
    $text200 = ("200")
    $text300 = ("300")
    #Region ### START Koda GUI section ### Form=
    ;fenster
    $Form1 = GUICreate("Form1", 461, 188, 192, 124)
    ;buttons mit 1. deklaration
    $Button1 = GUICtrlCreateButton($text001, 80, 24, 81, 33)
    $Button2 = GUICtrlCreateButton($text002, 184, 24, 81, 33)
    $Button3 = GUICtrlCreateButton($text003, 296, 24, 81, 33)
    ;input fenster leer unbeschreibbar
    $Input1 = GUICtrlCreateInput("", 80, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
    $Input2 = GUICtrlCreateInput("", 184, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
    $Input3 = GUICtrlCreateInput("", 296, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    ;buttonfunktions deklaration
    Case $Button1
    _Func1 ()
    Case $Button2
    _Func2 ()
    Case $Button3
    _Func3 ()
    EndSwitch
    WEnd

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

    ;funktionen für die buttons mit 1. text deklaration --> egal auf welchen butten geklickt wird es
    ;wird der text des buttons in das 1. inputfenster gesendet und die buttons erhalten die
    ;2.text deklaration
    Func _Func1 ()
    GUICtrlSetData($Input1, $text001 )

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

    ;buttons werden mit 2.text deklaration versehen
    GUICtrlSetData($button1, $text010 )
    GUICtrlSetData($button2, $text020 )
    GUICtrlSetData($button3, $text030 )
    EndFunc
    Func _Func2 ()
    GUICtrlSetData($Input1, $text002 )

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

    ;buttons werden mit 2.text deklaration versehen
    GUICtrlSetData($button1, $text010 )
    GUICtrlSetData($button2, $text020 )
    GUICtrlSetData($button3, $text030 )
    EndFunc
    Func _Func3 ()
    GUICtrlSetData($Input1, $text003 )

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

    ;buttons werden mit 2.text deklaration versehen
    GUICtrlSetData($button1, $text010 )
    GUICtrlSetData($button2, $text020 )
    GUICtrlSetData($button3, $text030 )
    EndFunc

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

    ;und wie gehst weiter???

    [/autoit]

    danke schon mal :thumbup:

    Einmal editiert, zuletzt von nuyx (17. Januar 2012 um 09:41)

  • Wirklich klar was du willst ist mir zwar nicht, aber vielleicht meinst das ja so:

    Spoiler anzeigen
    [autoit]

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

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

    Dim $text001[3] = ["001", "010", "100"]
    Dim $text002[3] = ["002", "020", "200"]
    Dim $text003[3] = ["003", "030", "300"]
    $count = 0

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

    #region ### START Koda GUI section ### Form=

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

    $Form1 = GUICreate("Form1", 461, 188, 192, 124)

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

    $Button1 = GUICtrlCreateButton($text001[0], 80, 24, 81, 33)
    $Button2 = GUICtrlCreateButton($text002[0], 184, 24, 81, 33)
    $Button3 = GUICtrlCreateButton($text003[0], 296, 24, 81, 33)

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

    $Input1 = GUICtrlCreateInput("", 80, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
    $Input2 = GUICtrlCreateInput("", 184, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
    $Input3 = GUICtrlCreateInput("", 296, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    _Func1($text001)
    Case $Button2
    _Func1($text002)
    Case $Button3
    _Func1($text003)
    EndSwitch
    WEnd

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

    Func _Func1($wert)
    Switch $count
    Case 0
    GUICtrlSetData($Input1, $wert[$count])
    Case 1
    GUICtrlSetData($Input2, $wert[$count])
    Case 2
    GUICtrlSetData($Input3, $wert[$count])
    EndSwitch

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

    $count = $count + 1
    If $count > 2 Then
    $count = 0
    EndIf

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

    GUICtrlSetData($Button1, $text001[$count])
    GUICtrlSetData($Button2, $text002[$count])
    GUICtrlSetData($Button3, $text003[$count])
    EndFunc ;==>_Func1

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

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Um den Text einer inputbox zu ändern kannst du

    [autoit]

    GuiCtrlSetData

    [/autoit]


    Benutzen.

    [autoit]

    GuiCtrlSetData($InputboxID, $Text)

    [/autoit]

    Ich hoffe ich konnte helfen!

    LG K.K.

    //Edit: chip war schneller :)

  • @ chip:

    hab grade mal dein skript ausprobiert und ja genau das ist es! danke dir! nur gibt es nun nur noch einen punkt und zwar an der stelle:

    Spoiler anzeigen
    [autoit]

    Dim $text001[3] = ["001", "010", "100"]

    [/autoit]

    müsste ich statt literalen eine deklarierte variable verwenden ... ich meine sowas in der art (das wäre z.b. die "001":

    Spoiler anzeigen
    [autoit]


    $text1 = Random(1, 9, 1)
    $text2 = Random(1, 9, 1)
    If $text1 = $text2 Then
    While 1
    $text2 = Random(1, 9, 1)
    If $text1 <> $text2 Then ExitLoop
    WEnd
    EndIf

    [/autoit]

    denn ich kann den zahlenwert nicht genau festlegen da es eine random zahl mit einschränkungen ist. müsste ich dann $text1, $text10 und dann $text100 anlegen und für die literale ["001", "010", "100"] ersetzten?


    K.K. danke ich kenne die befehle nur bin ich halt am lernen durch naja viel probieren ;)


    EDIT: lösung gefunden danke euch!!!

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    $text1 = Random(1, 9, 1)
    $text2 = Random(1, 9, 1)
    If $text1 = $text2 Then
    While 1
    $text2 = Random(1, 9, 1)
    If $text1 <> $text2 Then ExitLoop
    WEnd
    EndIf
    $text3 = random(1, 9, 1)
    If $text3 = $text1 Or $text3 = $text2 Then
    While 1
    $text3 = Random (1, 9, 1)
    If $text3 <> $text1 And $text3 <> $text2 Then ExitLoop
    WEnd
    EndIf
    $text10 = Random(1, 9, 1)
    $text20 = Random(1, 9, 1)
    If $text10 = $text20 Then
    While 1
    $text20 = Random(1, 9, 1)
    If $text10 <> $text20 Then ExitLoop
    WEnd
    EndIf
    $text30 = random(1, 9, 1)
    If $text30 = $text10 Or $text30 = $text20 Then
    While 1
    $text30 = Random (1, 9, 1)
    If $text30 <> $text10 And $text30 <> $text20 Then ExitLoop
    WEnd
    EndIf
    $text100 = Random(1, 9, 1)
    $text200 = Random(1, 9, 1)
    If $text100 = $text200 Then
    While 1
    $text200 = Random(1, 9, 1)
    If $text100 <> $text200 Then ExitLoop
    WEnd
    EndIf
    $text300 = random(1, 9, 1)
    If $text300= $text100 Or $text300 = $text200 Then
    While 1
    $text300 = Random (1, 9, 1)
    If $text300 <> $text100 And $text300 <> $text200 Then ExitLoop
    WEnd
    EndIf
    Dim $text001[3] = [$text1, $text10, $text100]
    Dim $text002[3] = [$text2, $text20, $text200]
    Dim $text003[3] = [$text3, $text30, $text300]
    $count = 0
    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 461, 188, 192, 124)
    $Button1 = GUICtrlCreateButton($text001[0], 80, 24, 81, 33)
    $Button2 = GUICtrlCreateButton($text002[0], 184, 24, 81, 33)
    $Button3 = GUICtrlCreateButton($text003[0], 296, 24, 81, 33)
    $Input1 = GUICtrlCreateInput("", 80, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
    $Input2 = GUICtrlCreateInput("", 184, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
    $Input3 = GUICtrlCreateInput("", 296, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    _Func1($text001)
    Case $Button2
    _Func1($text002)
    Case $Button3
    _Func1($text003)
    EndSwitch
    WEnd
    Func _Func1($wert)
    Switch $count
    Case 0
    GUICtrlSetData($Input1, $wert[$count])
    Case 1
    GUICtrlSetData($Input2, $wert[$count])
    Case 2
    GUICtrlSetData($Input3, $wert[$count])
    EndSwitch

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

    $count = $count + 1
    If $count > 2 Then
    $count = 0
    EndIf
    GUICtrlSetData($Button1, $text001[$count])
    GUICtrlSetData($Button2, $text002[$count])
    GUICtrlSetData($Button3, $text003[$count])
    EndFunc ;==>_Func1

    [/autoit]

    nun schau ich mir mal detailiert an warum das funktionier :))

    Einmal editiert, zuletzt von nuyx (17. Januar 2012 um 09:32)