Taschenrechner

  • Hier mein fertiger Taschenrechner. Freue mich über jede Kritik =)
    Beschäftige mich aber erst seit 10 Tagen mit AutoIt. Also bitte nicht zu viele Abkürzungen verwenden :)

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Rechner", 366, 320, 192, 124)
    GUISetBkColor(0x33CCFF)
    $Label1 = GUICtrlCreateLabel("", 40, 24, 283, 36)
    GUICtrlSetBkColor($Label1, 0xFFFFFF)
    GUICtrlSetFont($Label1, 21)
    $Button1 = GUICtrlCreateButton("1", 48, 80, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button1, 0x0099FF)
    GUICtrlSetColor($Button1, 0xFFFFFF)
    $Button2 = GUICtrlCreateButton("2", 104, 80, 41, 41, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("3", 160, 80, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button3, 0x0099FF)
    GUICtrlSetColor($Button3, 0xFFFFFF)
    $Button4 = GUICtrlCreateButton("4", 48, 136, 41, 41, $WS_GROUP)
    $Button5 = GUICtrlCreateButton("5", 104, 136, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button5, 0x0099FF)
    GUICtrlSetColor($Button5, 0xFFFFFF)
    $Button6 = GUICtrlCreateButton("6", 160, 136, 41, 41, $WS_GROUP)
    $Button7 = GUICtrlCreateButton("7", 48, 192, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button7, 0x0099FF)
    GUICtrlSetColor($Button7, 0xFFFFFF)
    $Button8 = GUICtrlCreateButton("8", 104, 192, 41, 41, $WS_GROUP)
    $Button9 = GUICtrlCreateButton("9", 160, 192, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button9, 0x0099FF)
    GUICtrlSetColor($Button9, 0xFFFFFF)
    $Button10 = GUICtrlCreateButton("0", 48, 248, 41, 41, $WS_GROUP)
    $Button11 = GUICtrlCreateButton("/", 216, 80, 41, 41, $WS_GROUP)
    $Button12 = GUICtrlCreateButton("*", 216, 136, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button12, 0x0099FF)
    GUICtrlSetColor($Button12, 0xFFFFFF)
    $Button13 = GUICtrlCreateButton("-", 216, 192, 41, 41, $WS_GROUP)
    $Button14 = GUICtrlCreateButton("+", 216, 248, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button14, 0x0099FF)
    GUICtrlSetColor($Button14, 0xFFFFFF)
    $Button15 = GUICtrlCreateButton(".", 104, 248, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button15, 0x0099FF)
    GUICtrlSetColor($Button15, 0xFFFFFF)
    $Button16 = GUICtrlCreateButton("=", 160, 248, 41, 41, $WS_GROUP)
    $Button17 = GUICtrlCreateButton("C", 272, 80, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button17, 0x0099FF)
    GUICtrlSetColor($Button17, 0xFFFFFF)
    $Button18 = GUICtrlCreateButton("(", 272, 136, 41, 41, $WS_GROUP)
    $Button19 = GUICtrlCreateButton(")", 272, 192, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button19, 0x0099FF)
    GUICtrlSetColor($Button19, 0xFFFFFF)
    $Button20 = GUICtrlCreateButton("Rücktaste", 272, 248, 82, 41, $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
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
    Case $Button2
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
    Case $Button3
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
    Case $Button4
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
    Case $Button5
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
    Case $Button6
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
    Case $Button7
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
    Case $Button8
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
    Case $Button9
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
    Case $Button10
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
    Case $Button11
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "/")
    Case $Button12
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "*")
    Case $Button13
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "-")
    Case $Button14
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "+")
    Case $Button15
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & ".")
    Case $Button16
    GUICtrlSetData($label1, Execute(GUICtrlRead($label1)))
    Case $Button17
    GUICtrlSetData($Label1, "")
    Case $Button18
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "(")
    Case $Button19
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & ")")
    Case $Button20
    $rLabel1 = GUICtrlRead($Label1)
    GUICtrlSetData($Label1, StringTrimRight($rLabel1, 1))
    EndSwitch
    WEnd

    [/autoit]

    mfG
    Charlie

  • Da haste dir aber was ausgedacht mit den Buttons xD

    Schöne Arbeit, nur tut man sich vllt bei den blauen Buttons etwas schwer zu erkennen ob sie gedrückt sind od nicht, damit kannst du dich ja mal beschäftigen.
    Aber echt gratulation, für 10 tage ist das nicht schlecht, weiter so!!!

    Mfg

    Computers are like Airconditioning. They don´t work with open Windows.

  • beim Teilen durch 0 kommt 1.#INF

    diesen Fehler könntest du noch abfangen, ansonsten schöne Arbeit :thumbup:

    weiter so :!:

    Zitat

    Laughing Man

    "I thought, what I'd do was, I'd pretend I was one of those deaf-mutes"

  • gute arbeit aber du könntest ja die buttons noch sortieren weil man sucht manchmal eine zeit um einen Button zu finden und die Schriftgröße der Buttons mit dem * noch erhöhen , da sie sehr klein sind

  • Habe den Rechner ein wenig verbessert (hoff ich ^^). Momentan kann man die Ergebnisse nur speichern. Muss mir noch was überlegen, damit die gespeicherten Ergebnisse auch verwendet werden können :)

    Hier ist er:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Rechner", 420, 320, 192, 124)
    GUISetBkColor(0x33CCFF)
    $Label1 = GUICtrlCreateLabel("", 40, 24, 340, 36)
    GUICtrlSetBkColor($Label1, 0xFFFFFF)
    GUICtrlSetFont($Label1, 21)
    $Button1 = GUICtrlCreateButton("1", 48, 80, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button1, 0x0099FF)
    GUICtrlSetColor($Button1, 0xFFFFFF)
    $Button2 = GUICtrlCreateButton("2", 104, 80, 41, 41, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("3", 160, 80, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button3, 0x0099FF)
    GUICtrlSetColor($Button3, 0xFFFFFF)
    $Button4 = GUICtrlCreateButton("4", 48, 136, 41, 41, $WS_GROUP)
    $Button5 = GUICtrlCreateButton("5", 104, 136, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button5, 0x0099FF)
    GUICtrlSetColor($Button5, 0xFFFFFF)
    $Button6 = GUICtrlCreateButton("6", 160, 136, 41, 41, $WS_GROUP)
    $Button7 = GUICtrlCreateButton("7", 48, 192, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button7, 0x0099FF)
    GUICtrlSetColor($Button7, 0xFFFFFF)
    $Button8 = GUICtrlCreateButton("8", 104, 192, 41, 41, $WS_GROUP)
    $Button9 = GUICtrlCreateButton("9", 160, 192, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button9, 0x0099FF)
    GUICtrlSetColor($Button9, 0xFFFFFF)
    $Button10 = GUICtrlCreateButton("0", 48, 248, 41, 41, $WS_GROUP)
    $Button11 = GUICtrlCreateButton("/", 216, 80, 41, 41, $WS_GROUP)
    GUICtrlSetFont($Button11, 12)
    $Button12 = GUICtrlCreateButton("*", 216, 136, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button12, 0x0099FF)
    GUICtrlSetColor($Button12, 0xFFFFFF)
    GUICtrlSetFont($Button12, 16)
    $Button13 = GUICtrlCreateButton("-", 216, 192, 41, 41, $WS_GROUP)
    GUICtrlSetFont($Button13, 13)
    $Button14 = GUICtrlCreateButton("+", 216, 248, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button14, 0x0099FF)
    GUICtrlSetColor($Button14, 0xFFFFFF)
    GUICtrlSetFont($Button14, 12)
    $Button15 = GUICtrlCreateButton(".", 104, 248, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button15, 0x0099FF)
    GUICtrlSetColor($Button15, 0xFFFFFF)
    GUICtrlSetFont($Button15, 15)
    $Button16 = GUICtrlCreateButton("=", 160, 248, 41, 41, $WS_GROUP)
    $Button17 = GUICtrlCreateButton("C", 272, 80, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button17, 0x0099FF)
    GUICtrlSetColor($Button17, 0xFFFFFF)
    $Button18 = GUICtrlCreateButton("(", 272, 136, 41, 41, $WS_GROUP)
    $Button19 = GUICtrlCreateButton(")", 328, 136, 41, 41, $WS_GROUP)
    GUICtrlSetBkColor($Button19, 0x0099FF)
    GUICtrlSetColor($Button19, 0xFFFFFF)
    $Button20 = GUICtrlCreateButton("Rücktaste", 272, 248, 99, 41, $WS_GROUP)
    GUISetState(@SW_SHOW)
    $Button21 = GUICtrlCreateButton("Ende", 328, 80, 41, 41, $WS_GROUP)
    $Button22 = GUICtrlCreateButton("Kopieren", 272, 192, 99, 41, $WS_GROUP)
    $Speichermenu1 = GUICtrlCreateMenu("Speichern in...")
    $Speichermenu2 = GUICtrlCreateMenu("Speicherplatz A", $Speichermenu1)
    $Speichermenu3 = GUICtrlCreateMenu("Speicherplatz B", $Speichermenu1)
    $Speichermenu4 = GUICtrlCreateMenu("Speicherplatz C", $Speichermenu1)
    $Speichermenu5 = GUICtrlCreateMenu("Speicherplatz D", $Speichermenu1)
    $Speichermenu6 = GUICtrlCreateMenu("Speicherplatz E", $Speichermenu1)
    $Loeschen = GUICtrlCreateMenuItem("Alle löschen",$Speichermenu1)
    $SlotA = GUICtrlCreateMenuItem("<leer>", $Speichermenu2)
    $SlotB = GUICtrlCreateMenuItem("<leer>", $Speichermenu3)
    $SlotC = GUICtrlCreateMenuItem("<leer>", $Speichermenu4)
    $SlotD = GUICtrlCreateMenuItem("<leer>", $Speichermenu5)
    $SlotE = GUICtrlCreateMenuItem("<leer>", $Speichermenu6)

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

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

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
    Case $Button2
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
    Case $Button3
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
    Case $Button4
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
    Case $Button5
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
    Case $Button6
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
    Case $Button7
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
    Case $Button8
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
    Case $Button9
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
    Case $Button10
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
    Case $Button11
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "/")
    Case $Button12
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "*")
    Case $Button13
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "-")
    Case $Button14
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "+")
    Case $Button15
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & ".")
    Case $Button16
    GUICtrlSetData($label1, Execute(GUICtrlRead($label1)))
    $Antwort = GUICtrlRead($Label1)
    If $Antwort = "1.#INF" Then ;<-- Klappt nicht sehr gut
    $Fehler = GUICtrlSetData($Label1, "Teilen durch 0 unmöglich!")
    EndIf
    Case $Button17
    GUICtrlSetData($Label1, "")
    Case $Button18
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "(")
    Case $Button19
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & ")")
    Case $Button20
    $rLabel1 = GUICtrlRead($Label1)
    GUICtrlSetData($Label1, StringTrimRight($rLabel1, 1))
    Case $Button21
    Exit
    Case $Button22
    ClipPut(GUICtrlRead($Label1))
    Case $SlotA
    $aLabel = GUICtrlRead($Label1)
    GUICtrlSetData($SlotA, $aLabel)
    Case $SlotB
    $aLabel = GUICtrlRead($Label1)
    GUICtrlSetData($SlotB, $aLabel)
    Case $SlotC
    $aLabel = GUICtrlRead($Label1)
    GUICtrlSetData($SlotC, $aLabel)
    Case $SlotD
    $aLabel = GUICtrlRead($Label1)
    GUICtrlSetData($SlotD, $aLabel)
    Case $SlotE
    $aLabel = GUICtrlRead($Label1)
    GUICtrlSetData($SlotE, $aLabel)
    Case $Loeschen
    GUICtrlSetData($SlotA, "<leer>")
    GUICtrlSetData($SlotB, "<leer>")
    GUICtrlSetData($SlotC, "<leer>")
    GUICtrlSetData($SlotD, "<leer>")
    GUICtrlSetData($SlotE, "<leer>")

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

    EndSwitch

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

    WEnd

    [/autoit]

    Bei Zeile 113 ist meine Variante nicht sehr vorteilhaft. Bei z.B. 1+0.123 klappt es nicht. Hat jemand einen anderen Vorschlag?

    Charlie

    Einmal editiert, zuletzt von Charlie (4. August 2009 um 11:46)