Inputfenster über Radiobutton auswählen.

  • Hallo alle zusammen. Ich steh noch am Anfang von Autoit. Ich bau gerade ein kleines Programm und komme einfach nicht weiter. Ich habe 16 Button. Jeder Button ist mit einer bestimmten Zahl hinterlegt.
    Es soll so funktionieren. Ich wähle das gewünschte Inputfenster mit dem Radiobutton aus und drücke dann einen Button von 16 Stück einen. z.b. Button 2 , der den Wet 50 hat. Dann soll die Zahl 50
    im ausgewählten Inputfenster stehen. Drücke ich noch mal den Button, soll er die Zahl einfach zusammen rechnen. 50+50= 100. Würde mich über Tipps von Euch freuen :)

    Dazu ein Beispiel nochmal
    [Blockierte Grafik: http://cdn.imghack.se/medium/8a676b3cd9e64145c9e85f0548d709d4.jpg]

    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("test", 560, 346, 265, 197)
    GUISetBkColor(0xFFFFFF)
    $Label1 = GUICtrlCreateLabel("1:", 8, 8, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label7 = GUICtrlCreateLabel("4.:", 8, 80, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label2 = GUICtrlCreateLabel("2:", 8, 32, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label3 = GUICtrlCreateLabel("3:", 8, 56, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label4 = GUICtrlCreateLabel("6:", 8, 128, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label5 = GUICtrlCreateLabel("5:", 8, 104, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Input1 = GUICtrlCreateInput("", 80, 8, 121, 21)
    $Input2 = GUICtrlCreateInput("", 80, 32, 121, 21)
    $Input4 = GUICtrlCreateInput("", 80, 80, 121, 21)
    $Input3 = GUICtrlCreateInput("", 80, 56, 121, 21)
    $Input5 = GUICtrlCreateInput("", 80, 104, 121, 21)
    $Input6 = GUICtrlCreateInput("", 80, 128, 121, 21)
    $Radio1 = GUICtrlCreateRadio("", 352, 8, 113, 17)
    $Radio2 = GUICtrlCreateRadio("", 352, 32, 113, 17)
    $Radio3 = GUICtrlCreateRadio("", 352, 56, 113, 17)
    $Radio4 = GUICtrlCreateRadio("", 352, 80, 113, 17)
    $Radio5 = GUICtrlCreateRadio("", 352, 104, 113, 17)
    $Radio6 = GUICtrlCreateRadio("", 352, 128, 113, 17)
    $Input7 = GUICtrlCreateInput("", 224, 8, 121, 21)
    $Input8 = GUICtrlCreateInput("", 224, 32, 121, 21)
    $Input9 = GUICtrlCreateInput("", 224, 56, 121, 21)
    $Input10 = GUICtrlCreateInput("", 224, 80, 121, 21)
    $Input11 = GUICtrlCreateInput("", 224, 104, 121, 21)
    $Input12 = GUICtrlCreateInput("", 224, 128, 121, 21)
    $Button1 = GUICtrlCreateButton("", 8, 160, 131, 25)
    $Button2 = GUICtrlCreateButton("", 8, 224, 131, 25)
    $Button3 = GUICtrlCreateButton("", 8, 256, 131, 25)
    $Button4 = GUICtrlCreateButton("", 8, 192, 131, 25)
    $Button5 = GUICtrlCreateButton("", 144, 160, 131, 25)
    $Button6 = GUICtrlCreateButton("", 144, 224, 131, 25)
    $Button7 = GUICtrlCreateButton("", 144, 256, 131, 25)
    $Button8 = GUICtrlCreateButton("", 144, 192, 131, 25)
    $Button9 = GUICtrlCreateButton("", 280, 160, 131, 25)
    $Button10 = GUICtrlCreateButton("", 280, 224, 131, 25)
    $Button11 = GUICtrlCreateButton("", 280, 256, 131, 25)
    $Button12 = GUICtrlCreateButton("", 280, 192, 131, 25)
    $Button13 = GUICtrlCreateButton("", 416, 160, 131, 25)
    $Button14 = GUICtrlCreateButton("", 416, 224, 131, 25)
    $Button15 = GUICtrlCreateButton("", 416, 256, 131, 25)
    $Button16 = GUICtrlCreateButton("", 416, 192, 131, 25)
    GUICtrlSetFont(-1, 30, 400, 0, "Rage Italic LET")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $nMsg = $Button1
    $read1 = 50
    $Ergebnis = $read1
    GUICtrlSetData($Input12, GUICtrlRead($Input12)+$Ergebnis)
    EndSwitch
    WEnd

    [/autoit]

    Einmal editiert, zuletzt von BTXUser (3. November 2011 um 18:38)

  • Wird das ein AP-Rechner für AION?

    Sieht zumindest so aus... 6 Input-Felder für die Gruppenmitglieder und 4 Button-Gruppen zu je 4 Buttons für die 4 verschiedenen Wertigkeiten der unterschiedlichen AP-Item-Arten :)

    UNPLEASANT SPOILER

    You just lost the game!

    • Offizieller Beitrag

    Am einfachsten ist dein Vorhaben mit Arrays zu lösen.
    Da ich gerade nix besseres zu tun hatte, habe ich dir mal dein Beispiel angepaßt.

    Spoiler anzeigen
    [autoit]

    #Region - Timestamp
    ; 2011-11-03 17:12:04
    #EndRegion

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

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    Global $aRadio[6]; Array für die Aufnahme der Radios
    Global $aInput[6]; Array für die Aufnahme der Inputs an 1. Stelle
    Global $aInputB[6]; Array für die Aufnahme der Inputs an 2. Stelle
    Global $Focus
    #region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("test", 560, 346, 265, 197)
    GUISetBkColor(0xFFFFFF)
    $Label1 = GUICtrlCreateLabel("1:", 8, 8, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label7 = GUICtrlCreateLabel("4.:", 8, 80, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label2 = GUICtrlCreateLabel("2:", 8, 32, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label3 = GUICtrlCreateLabel("3:", 8, 56, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label4 = GUICtrlCreateLabel("6:", 8, 128, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $Label5 = GUICtrlCreateLabel("5:", 8, 104, 70, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "Microsoft Sans Serif")
    $aInput[0] = GUICtrlCreateInput("", 80, 8, 121, 21)
    $aInputB[0] = GUICtrlCreateInput("", 224, 8, 121, 21)
    $aInput[1] = GUICtrlCreateInput("", 80, 32, 121, 21)
    $aInputB[1] = GUICtrlCreateInput("", 224, 32, 121, 21)
    $aInput[2] = GUICtrlCreateInput("", 80, 56, 121, 21)
    $aInputB[2] = GUICtrlCreateInput("", 224, 56, 121, 21)
    $aInput[3] = GUICtrlCreateInput("", 80, 80, 121, 21)
    $aInputB[3] = GUICtrlCreateInput("", 224, 80, 121, 21)
    $aInput[4] = GUICtrlCreateInput("", 80, 104, 121, 21)
    $aInputB[4] = GUICtrlCreateInput("", 224, 104, 121, 21)
    $aInput[5] = GUICtrlCreateInput("", 80, 128, 121, 21)
    $aInputB[5] = GUICtrlCreateInput("", 224, 128, 121, 21)
    $aRadio[0] = GUICtrlCreateRadio("", 352, 8, 113, 17)
    $aRadio[1] = GUICtrlCreateRadio("", 352, 32, 113, 17)
    $aRadio[2] = GUICtrlCreateRadio("", 352, 56, 113, 17)
    $aRadio[3] = GUICtrlCreateRadio("", 352, 80, 113, 17)
    $aRadio[4] = GUICtrlCreateRadio("", 352, 104, 113, 17)
    $aRadio[5] = GUICtrlCreateRadio("", 352, 128, 113, 17)
    ; Ab hier stimmt die Reihenfolge nicht mit der Anzeigeposition überein.
    $Button1 = GUICtrlCreateButton("50", 8, 160, 131, 25)
    $Button2 = GUICtrlCreateButton("100", 8, 224, 131, 25)
    $Button3 = GUICtrlCreateButton("150", 8, 256, 131, 25)
    $Button4 = GUICtrlCreateButton("200", 8, 192, 131, 25)
    $Button5 = GUICtrlCreateButton("250", 144, 160, 131, 25)
    $Button6 = GUICtrlCreateButton("300", 144, 224, 131, 25)
    $Button7 = GUICtrlCreateButton("350", 144, 256, 131, 25)
    $Button8 = GUICtrlCreateButton("400", 144, 192, 131, 25)
    $Button9 = GUICtrlCreateButton("450", 280, 160, 131, 25)
    $Button10 = GUICtrlCreateButton("500", 280, 224, 131, 25)
    $Button11 = GUICtrlCreateButton("550", 280, 256, 131, 25)
    $Button12 = GUICtrlCreateButton("600", 280, 192, 131, 25)
    $Button13 = GUICtrlCreateButton("650", 416, 160, 131, 25)
    $Button14 = GUICtrlCreateButton("700", 416, 224, 131, 25)
    $Button15 = GUICtrlCreateButton("750", 416, 256, 131, 25)
    $Button16 = GUICtrlCreateButton("800", 416, 192, 131, 25)
    GUICtrlSetFont(-1, 30, 400, 0, "Rage Italic LET")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    GUICtrlSetState($aRadio[0],$GUI_CHECKED); 1. Radiobutton checken
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $aRadio[0] To $aRadio[5]
    Local $iSelect = $nMsg - $aRadio[0]; Hier wird der Index des gedrückten Radios ermittelt
    ControlFocus($Form1_1, "", $aInput[$iSelect]); Eingabefocus auf das Input setzen, welches vor dem Radiobutton steht
    $Focus = $iSelect; Index des Radios für spätere verwendung bei den Buttons speichern
    Case $Button1
    $read1 = 50
    GUICtrlSetData($aInput[$Focus],$read1); Der Wert des Buttons wird im 1. Input am selektierten Radio eingetragen
    GUICtrlSetData($aInputB[$Focus], GUICtrlRead($aInputB[$Focus]) + $read1); Input am gewählten Radio auslesen und + 50 hinzurechnen, Wert wieder in Input schreiben
    Case $Button2
    $read1 = 100
    GUICtrlSetData($aInput[$Focus],$read1); Der Wert des Buttons wird im 1. Input am selektierten Radio eingetragen
    GUICtrlSetData($aInputB[$Focus], GUICtrlRead($aInputB[$Focus]) + $read1); ; Input am gewählten Radio auslesen und + 100 hinzurechnen, Wert wieder in Input schreiben
    EndSwitch
    WEnd

    [/autoit]

    Im Augenblick sind nur Button1 und Button2 mit einem Wert belegt.
    Du mußt dir aber mal die Teihenfolge deiner Controls genauer ansehen. Die stimmen so nicht, ein großer NAchteil wenn man mit Koda arbeitet.
    Was ich damit meine siehst du wenn du dir mal die Werte der Buttons und dessen Position ansiehst.

    Edit: In meinem Besiepiel wird der Wert des Buttons im 1. Input eingetragen und das Rechenergebnis im 2. Input.
    Edit2: Btw. solltest du bei der Verwendung von Switch auch richtig abfragen
    Dieser Befehl:

    [autoit]

    Case $nMsg = $Button1

    [/autoit]


    Wäre nur sinnvoll wenn du mit Select arbeiteste, das ist auch der Grund warum in deinem Beispiel unentwegt hochgezählt wird.
    Die Richtig Abfrage ist:

    [autoit]

    Case $Button1

    [/autoit]
  • Hey Danke Raupi für deine so umfangreiche Antwort. Du hast mir sehr gut geholfen. Jetzt kann ich weiter basteln und ja es wird ein AP-Relikt Rechner^^. Man, da hat aber jemand gut Augen^^

    Einmal editiert, zuletzt von BTXUser (4. November 2011 um 17:46)