Code-Schloss

  • Hallo, ich stehe vor der Frage, wie es am kürzesten und am einfachsten ist, ein Code schloss mit 4 Eingaben zu gestallten. Hier meine GUI:

    Spoiler anzeigen
    [autoit]

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

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

    $Code = GUICreate("Code-Schloss", 633, 234, 192, 124)
    $Taste1 = GUICtrlCreateButton("Taste 1", 100, 120, 73, 65, $WS_GROUP)
    $Taste2 = GUICtrlCreateButton("Taste 2", 220, 120, 73, 65, $WS_GROUP)
    $Taste3 = GUICtrlCreateButton("Taste 3", 340, 120, 73, 65, $WS_GROUP)
    $Taste4 = GUICtrlCreateButton("Taste 4", 460, 120, 73, 65, $WS_GROUP)
    $Antwort1 = GUICtrlCreateLabel("Ungelöst", 221, 32, 190, 58)
    GUICtrlSetFont(-1, 24, 800, 0, "Year supply of fairy cakes")
    GUISetState(@SW_SHOW)

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

    While 1

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

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]

    Es geht darum, dass man die 4 Tasten in einer bestimmten Reihenfolge drücken muss, das dan eben gelöst darsteht. Also zum beispiel 1-4-2-3. Sollte man aber 1-4-3-2 drücken, soll es sich wider bei der falschen 3,reseten. Also sobald eine Zahl falsch der Reihenfolge ist, soll man von vorne Anfangen. Damit möchte ich bezwecken, das mann ganz sicher die Richtige Reihenfolghe kennt ;)

    lg Tim

    pS: Wie ist das am einfachsten zu lösen. (Ich meine damit am Script-übersichlichsten)

  • Das ist irgendwie sinnlos das immer wieder zu reseten, so kannst du dann durch Versuchen den richtigen Code herausfinden.

  • Beispiel:

    Spoiler anzeigen
    [autoit]

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

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

    $richtigerCode = "1423"
    $eingabe = ""
    $Code = GUICreate("Code-Schloss", 633, 234, 192, 124)
    $Taste1 = GUICtrlCreateButton("Taste 1", 100, 120, 73, 65, $WS_GROUP)
    $Taste2 = GUICtrlCreateButton("Taste 2", 220, 120, 73, 65, $WS_GROUP)
    $Taste3 = GUICtrlCreateButton("Taste 3", 340, 120, 73, 65, $WS_GROUP)
    $Taste4 = GUICtrlCreateButton("Taste 4", 460, 120, 73, 65, $WS_GROUP)
    $Antwort1 = GUICtrlCreateLabel("Ungelöst", 221, 32, 190, 58)
    GUICtrlSetFont(-1, 24, 800, 0, "Year supply of fairy cakes")
    GUISetState(@SW_SHOW)

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Taste1
    $eingabe &= 1
    Case $Taste2
    $eingabe &= 2
    Case $Taste3
    $eingabe &= 3
    Case $Taste4
    $eingabe &= 4
    EndSwitch
    If StringLen($eingabe) = 4 Then
    If $eingabe = $richtigerCode Then
    MsgBox(0, '', 'Code geknackt')
    $eingabe = ""
    Else
    MsgBox(0, '', 'falscher Code')
    $eingabe = ""
    EndIf
    EndIf
    WEnd

    [/autoit]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    über mich...

    ich habe meine Erfahrungen hauptsächlich gesammelt in (grobe Übersicht):

    - RibbonBar Automation
    - MySQL Nutzung
    - GUIs in vielerlei Ausprägung
    - Nutzung von Powershell / Batch in AutoIt
    - Windows Automatisierung

    außerhalb von AutoIt:

    - Sprachen: PS, Batch, php, html(5), javascript, (perl eingeschränkt), vbs
    - Powershell (AD, WPF inkl. Multi-Threading, ...)
    - Deployment-Automatisierung ohne SCCM
    - Office-Nutzung mit COM-Object (AutoIt, PowerShell)
    - ActiveDirectory und alles was damit zusammenhängt
    - Hyper-V Clustering (Converged / Hyper Converged)
    - Serverhardware (Konfiguration, Aufbau, Architektur, Betrieb)

    Lieblingsthema:

    günstige Automatisierung von Vorgängen, für die andere Firmen viel Geld nehmen

    more to come ...

  • So wär mein Beispiel:

    [autoit]

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

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

    Local $sCorrect = "3214", $sPW

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

    $Code = GUICreate("Code-Schloss", 633, 234, 192, 124)
    $Taste1 = GUICtrlCreateButton("Taste 1", 100, 120, 73, 65, $WS_GROUP)
    $Taste2 = GUICtrlCreateButton("Taste 2", 220, 120, 73, 65, $WS_GROUP)
    $Taste3 = GUICtrlCreateButton("Taste 3", 340, 120, 73, 65, $WS_GROUP)
    $Taste4 = GUICtrlCreateButton("Taste 4", 460, 120, 73, 65, $WS_GROUP)
    $Antwort1 = GUICtrlCreateLabel("Ungelöst", 221, 32, 190, 58)
    GUICtrlSetFont(-1, 24, 800, 0, "Year supply of fairy cakes")
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Taste1 To $Taste4
    $sPW &= StringReplace(GUICtrlRead($nMsg), "Taste ", "")
    If StringLeft($sCorrect, StringLen($sPW)) <> $sPW Then $sPW = ""
    If StringLen($sPW) = StringLen($sCorrect) Then GUICtrlSetData($Antwort1,"Gelöst")
    EndSwitch
    WEnd

    [/autoit]
  • [autoit]

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

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

    $vorgabe="3241"

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

    $Code = GUICreate("Code-Schloss", 633, 234, 192, 124)
    $Taste1 = GUICtrlCreateButton("Taste 1", 100, 120, 73, 65, $WS_GROUP)
    $Taste2 = GUICtrlCreateButton("Taste 2", 220, 120, 73, 65, $WS_GROUP)
    $Taste3 = GUICtrlCreateButton("Taste 3", 340, 120, 73, 65, $WS_GROUP)
    $Taste4 = GUICtrlCreateButton("Taste 4", 460, 120, 73, 65, $WS_GROUP)
    $Antwort1 = GUICtrlCreateLabel("Ungelöst", 221, 32, 190, 58)
    GUICtrlSetFont(-1, 24, 800, 0, "Year supply of fairy cakes")
    GUISetState(@SW_SHOW)

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

    $a=""
    While 1
    $msg=guigetmsg()
    Switch $msg
    Case $taste1,$taste2,$taste3,$Taste4
    $a&=stringright(guictrlread($msg),1)
    if $a<>stringleft($vorgabe,stringlen($a)) Then
    msgbox(0,"Falsche Eingabe!","Programm wird beendet")
    Exit
    endif
    if $a=$vorgabe then
    msgbox(0,"Richtige Eingabe", "Programm wird fortgesetzt")
    exitloop
    endif
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

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

    msgbox(0,"Weiter","hier gehts weiter....")

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


    SeuBo, deins ist besser, es resettet nicht^^

  • Habe mal so am Rande ein eigenes Schloss mit Zahlenkombination programmiert:

    [autoit]

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

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

    Opt("GUIOnEventMode", 1)

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

    Global $aButton[4]
    Global $iAnfangsPos = 8
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Schloss", 185, 56, 192, 124)
    GUISetOnEvent(-3,'_Exit',$Form1)
    For $i = 0 To 3 Step +1
    $aButton[$i] = GUICtrlCreateButton("0", $iAnfangsPos, 16, 35, 25, $WS_GROUP)
    GUICtrlSetOnEvent($aButton[$i],'_Make')
    $iAnfangsPos += 40
    Next
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    WEnd

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

    Func _Make()
    Local $iRes = ''
    GUICtrlSetData(@GUI_CtrlId,GUICtrlRead(@GUI_CtrlId) +1)
    If GUICtrlRead(@GUI_CtrlId) > 9 Then
    GUICtrlSetData(@GUI_CtrlId,'0')
    EndIf
    For $i = 0 To UBound($aButton) -1 Step +1
    $iRes &= GUICtrlRead($aButton[$i])
    Next
    If $iRes = '1337' Then Exit MsgBox(64,'Gelöst','Du hast das Passwort geknackt!')
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc

    [/autoit]