Sign in to follow this  
Followers 0
icadea

password represented by colour

1 post in this topic

This idea comes from seeing Piano Man's memory game.

This is a replacement code for password. Instead of typing in the password, it just click on the preprogrammed colours(which act like a password and have them give access to the program..

The password is GREEN, BLUE, PURPLE. and it'll exit

If one sequence is done in mistake it'll reset back the cycle.

I was wondering if there is a much simpler way in terms of repeating the same code. Can this be done with a few lines of code.

Please advise. thanks

#include <GUIConstants.au3>

menu()

Func dummy()
    menu()
EndFunc  ;==>dummy

Func menu()
    
    $Form1 = GUICreate("Form1", 462, 95, 213, 130)
    GUISetBkColor(0x000000)
    $Button1 = GUICtrlCreateButton("", 8, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x008000)
    $Button2 = GUICtrlCreateButton("", 96, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x0000FF)
    $Button3 = GUICtrlCreateButton("", 184, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x800080)
    $Button4 = GUICtrlCreateButton("", 272, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFFFF00)
    $Button5 = GUICtrlCreateButton("", 360, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $Button6 = GUICtrlCreateButton("x", 440, 72, 17, 17, 0)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)
    
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Button1
                pass1()
            Case $Button2
                dummy()
            Case $Button3
                dummy()
            Case $Button4
                dummy()
            Case $Button5
                dummy()
            Case $Button6
                Exit
        EndSwitch
    WEnd

EndFunc  ;==>menu

Func pass1()

    $Form1 = GUICreate("Form1", 462, 95, 213, 130)
    GUISetBkColor(0x000000)
    $Button1 = GUICtrlCreateButton("", 8, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x008000)
    $Button2 = GUICtrlCreateButton("", 96, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x0000FF)
    $Button3 = GUICtrlCreateButton("", 184, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x800080)
    $Button4 = GUICtrlCreateButton("", 272, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFFFF00)
    $Button5 = GUICtrlCreateButton("", 360, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $Button6 = GUICtrlCreateButton("x", 440, 72, 17, 17, 0)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Button1
                dummy()
            Case $Button2
                pass2()
            Case $Button3
                dummy()
            Case $Button4
                dummy()
            Case $Button5
                dummy()
            Case $Button6
                Exit
        EndSwitch
    WEnd

EndFunc  ;==>pass1

Func pass2()

    $Form1 = GUICreate("Form1", 462, 95, 213, 130)
    GUISetBkColor(0x000000)
    $Button1 = GUICtrlCreateButton("", 8, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x008000)
    $Button2 = GUICtrlCreateButton("", 96, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x0000FF)
    $Button3 = GUICtrlCreateButton("", 184, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x800080)
    $Button4 = GUICtrlCreateButton("", 272, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFFFF00)
    $Button5 = GUICtrlCreateButton("", 360, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $Button6 = GUICtrlCreateButton("x", 440, 72, 17, 17, 0)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Button1
                dummy()
            Case $Button2
                dummy()
            Case $Button3
                Exit
            Case $Button4
                dummy()
            Case $Button5
                dummy()
            Case $Button6
                Exit
        EndSwitch
    WEnd

EndFunc  ;==>pass2

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0