Sign in to follow this  
Followers 0
youknowwho4eva

Passcode script

12 posts in this topic

#1 ·  Posted (edited)

I know its not that impressive, and probably could be done a lot better, but I'm still proud of myself for it. This is my first script that I wrote without "borrowing" script from other sources that I don't yet understand what it does. I would like to see suggestions for cleaning it up if you have any, I'm sure I made it twice as long as it needs to be. I'm also attempting to make a png gui for it, but I'm still a little while away from understanding all that code. A high five for some one that purdies it up with a png gui, and another high five for someone that explain to me how it works :-P

Edit: I forgot, incase you dont want to go through the code to figure it out, the password is 1234

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

opt("guioneventmode",1)

Dim $digit1, $digit2, $digit3, $digit4

$1 = 0
$2 = 0
$3 = 0
$4 = 0

$maingui = GUICreate("Enter Pin?", 170, 200)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetOnEvent($gui_event_close, "bye")



$1button = GUICtrlCreateButton("1", 10, 40, 50)
GUICtrlSetOnEvent($1button, "onebutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$2button = GUICtrlCreateButton("2", 60, 40, 50)
GUICtrlSetOnEvent($2button, "twobutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$3button = GUICtrlCreateButton("3", 110, 40, 50)
GUICtrlSetOnEvent($3button, "threebutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$4button = GUICtrlCreateButton("4", 10, 80, 50)
GUICtrlSetOnEvent($4button, "fourbutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$5button = GUICtrlCreateButton("5", 60, 80, 50)
GUICtrlSetOnEvent($5button, "fivebutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$6button = GUICtrlCreateButton("6", 110, 80, 50)
GUICtrlSetOnEvent($6button, "sixbutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$7button = GUICtrlCreateButton("7", 10, 120, 50)
GUICtrlSetOnEvent($7button, "sevenbutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$8button = GUICtrlCreateButton("8", 60, 120, 50)
GUICtrlSetOnEvent($8button, "eightbutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$9button = GUICtrlCreateButton("9", 110, 120, 50)
GUICtrlSetOnEvent($9button, "ninebutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$0button = GUICtrlCreateButton("0", 60, 160, 50)
GUICtrlSetOnEvent($0button, "zerobutton")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)


guisetstate()

func onebutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "1"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "1"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "1"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "1"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func twobutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "2"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "2"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "2"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "2"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func threebutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "3"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "3"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "3"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "3"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func fourbutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "4"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "4"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "4"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "4"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            If $digit1 = 1 and $digit2 = 2 and $digit3 = 3 and $digit4 = 4 Then
                MsgBox(0, "Welcome", "Hello")
            Else
                MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            EndIf
            
        Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func fivebutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "5"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "5"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "5"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "5"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func sixbutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "6"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "6"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "6"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "6"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func sevenbutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "7"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "7"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "7"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "7"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
                EndIf
                    
            MsgBox(0, "Broken", "You Broke It")
            Exit
            
        
    EndIf
EndFunc

func eightbutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "8"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "8"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "8"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "8"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            
        Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func ninebutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "9"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "9"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "9"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "9"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            
        Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func zerobutton()
    If $1 = 0 then
        $1 += 1
        $digit1 = "0"
        GUICtrlCreateLabel("*", 10, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $1 = 1 and $2 = 0 then
        $2 += 1
        $digit2 = "0"
        GUICtrlCreateLabel("*", 30, 10)
        GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
    Else
        if $2 = 1 and $3 = 0 then
            $3 += 1
            $digit3 = "0"
            GUICtrlCreateLabel("*", 50, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
        ElseIf $3 = 1 and $4 = 0 then
            $4 += 1
            $digit4 = "0"
            GUICtrlCreateLabel("*", 70, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            MsgBox(0, "Bad", "No")
            $1 -= 1
            $2 -= 1
            $3 -= 1
            $4 -= 1
            GUICtrlCreateLabel("                               ", 10, 10)
            GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
            
        Else
            MsgBox(0, "Broken", "You Broke It")
            Exit
        EndIf
    EndIf
EndFunc

func bye()
    Exit
endfunc

while 1
    sleep(100)
wend
Edited by youknowwho4eva

Giggity

Share this post


Link to post
Share on other sites



I somehow broke it typing "257" ...dunno.

Anyway, much simpler version (something for you to think about) -

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

opt("guioneventmode",1)

Global $pass = "", $key = "1234", $keylen = StringLen($key)

$maingui = GUICreate("Enter Pin?", 170, 200)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetOnEvent($gui_event_close, "bye")


$pin = GUICtrlCreateLabel("", 10, 10, 150, 20)
GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
$1button = GUICtrlCreateButton("1", 10, 40, 50)
GUICtrlSetOnEvent($1button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$2button = GUICtrlCreateButton("2", 60, 40, 50)
GUICtrlSetOnEvent($2button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$3button = GUICtrlCreateButton("3", 110, 40, 50)
GUICtrlSetOnEvent($3button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$4button = GUICtrlCreateButton("4", 10, 80, 50)
GUICtrlSetOnEvent($4button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$5button = GUICtrlCreateButton("5", 60, 80, 50)
GUICtrlSetOnEvent($5button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$6button = GUICtrlCreateButton("6", 110, 80, 50)
GUICtrlSetOnEvent($6button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$7button = GUICtrlCreateButton("7", 10, 120, 50)
GUICtrlSetOnEvent($7button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$8button = GUICtrlCreateButton("8", 60, 120, 50)
GUICtrlSetOnEvent($8button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$9button = GUICtrlCreateButton("9", 110, 120, 50)
GUICtrlSetOnEvent($9button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$0button = GUICtrlCreateButton("0", 60, 160, 50)
GUICtrlSetOnEvent($0button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)


guisetstate()

Func _ButtonPress()
    Local $digit
    
    $pass &= GUICtrlRead(@GUI_CtrlId)
    GUICtrlSetData($pin, GUICtrlRead($pin) & "*")
EndFunc

func bye()
    Exit
endfunc

while 1
    If StringLen($pass) == $keylen Then
        If $pass == $key Then
            MsgBox(0, "", "Correct")
        Else
            MsgBox(0, "", "Wrong")
        EndIf
        $pass = ""
        GUICtrlSetData($pin, "")
    ElseIf StringLen($pass) > $keylen Then
    ; that's some superfast clicking son!
        $pass = ""
        GUICtrlSetData($pin, "")
    EndIf
    Sleep(100)
wend

Share this post


Link to post
Share on other sites

Thank you much I will try it out, and replace func sevenbutton() with this, it will fix it. :-P I changed the code from ending in 7 to 1234 and messed up while moving things. And if you put in the correct code then hit a fifth button it will tell you its broken, but thats intentional.

func sevenbutton()

If $1 = 0 then

$1 += 1

$digit1 = "7"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "7"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "7"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "7"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc


Giggity

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I tried out your script, and picked it apart till I understood it, thanks. But I have a question for you. I changed this

ElseIf StringLen($pass) > $keylen Then
  ; that's some superfast clicking son!
        $pass = ""
        GUICtrlSetData($pin, "")

to instead pop up a message, and changed it so if you enter the right code it adds a unit to the length of the $pass so that you can obtain a stringlegth for the password longer then the stringlength of the key, but the message doesn't pop up. Here's the full code of what I did If thats not clear, I also changed a few other small things. Still a high five for the help. muttley

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

opt("guioneventmode",1)

Global $pass = "", $key = "1234", $keylen = StringLen($key)

$maingui = GUICreate("Enter Pin", 170, 200)
GUISetOnEvent($gui_event_close, "bye")


$pin = GUICtrlCreateLabel("", 10, 10, 150, 20)
GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')
$1button = GUICtrlCreateButton("1", 10, 40, 50)
GUICtrlSetOnEvent($1button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$2button = GUICtrlCreateButton("2", 60, 40, 50)
GUICtrlSetOnEvent($2button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$3button = GUICtrlCreateButton("3", 110, 40, 50)
GUICtrlSetOnEvent($3button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$4button = GUICtrlCreateButton("4", 10, 80, 50)
GUICtrlSetOnEvent($4button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$5button = GUICtrlCreateButton("5", 60, 80, 50)
GUICtrlSetOnEvent($5button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$6button = GUICtrlCreateButton("6", 110, 80, 50)
GUICtrlSetOnEvent($6button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$7button = GUICtrlCreateButton("7", 10, 120, 50)
GUICtrlSetOnEvent($7button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$8button = GUICtrlCreateButton("8", 60, 120, 50)
GUICtrlSetOnEvent($8button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$9button = GUICtrlCreateButton("9", 110, 120, 50)
GUICtrlSetOnEvent($9button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$0button = GUICtrlCreateButton("0", 60, 160, 50)
GUICtrlSetOnEvent($0button, "_ButtonPress")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)


guisetstate()

Func _ButtonPress()
    Local $digit
    
    $pass &= GUICtrlRead(@GUI_CtrlId)
    GUICtrlSetData($pin, GUICtrlRead($pin) & "*")
EndFunc

func bye()
    Exit
endfunc

while 1
    Select
    Case StringLen($pass) == $keylen
        If $pass = $key Then
            MsgBox(0, "", "Correct")
            $pass = GUICtrlRead(@gui_ctrlid)
        Elseif $pass <> $key Then
            MsgBox(0, "", "No Soup for You")
            GUICtrlSetData($pin, "")
            $pass = ""
            Else
        EndIf
        
        
    Case StringLen($pass) > StringLen($key)
        
            MsgBox (0, "", "You can stop now you got it right")
        
        
    
    EndSelect
    Sleep(100)
wend
Edited by youknowwho4eva

Giggity

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Your while loop is weird now. Why do you do this?

$pass = GUICtrlRead(@gui_ctrlid)

That sets the value of $pass to the text of the control associated with the Control ID stored in the @Gui_CtrlId macro, which should be the last button clicked. I don't see the purpose here. What are you trying to accomplish?

You also have what seems an extraneous 'Else' right before your 'EndIf'.

If you simply want to display a message that the password length has been reached and you have to exit, then in the While loop remove any line that resets the value of $pass in your "success" test ($pass == $key), then in your buttonclick function add a test for the length of $pass, and if it's greater than or equal to $keylen, display your "You can stop now..." message box, and do not alter the value of $pass or change the data of $pin.

Edited by wraithdu

Share this post


Link to post
Share on other sites

I know a lot of it seems weird and unnecessary, but I'm just trying to grasp a fuller understanding of how things work and why. I can go around pulling the script from others designs and get what I want, but I would like to be able to make a script one day, without having to come to the forum, and maybe even not open the help file muttley . So far everyones help has helped me progress farther faster then I could have hoped for. I also hope to be able to think about it the way you more advanced users do. Having only just started playing with autoit I still think very linear, where your script (even if I had knowledge of those commands before) I would have never thought to do it that way. So I'm trying to wrap my brain around that thought process to hopefully make nice clean pretty scripts some day. I'm also thinking with this script, if it doesn't erase the password they someone wouldn't know how long the code is they are trying to figure out.


Giggity

Share this post


Link to post
Share on other sites

I thought your first post was quite funny, so here's my random friendly act for the day. muttley

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

;opt("guioneventmode",1) ;; On event mode is generally not necessary if you are not doing other things beside the GUI. 
                         ;; Although it is handy, I have found that writing AutoIt scripts generally works better without using OnEventMode.

;Global $pass = "", $key = "1234", $keylen = StringLen($key) ;; Defining globals here is also not required, you can just Dim them there,
                                                             ;;and they can be accessed in your script anywhere, but not outside it in any includes

Dim $sPass = "1337"

$guiMain = GUICreate("Enter Pin", 170, 200) ;; Instead of using variable names like $maingui, use something like $guiMain,
                                             ;; this later comes in handy when you want to use intellisense to find your variables that have to do with your GUI specfically
                                             ;; and you don't want to find things that have to do with "main" :P
GUISetBkColor(0x555555)
;GUISetOnEvent($gui_event_close, "bye")

$guiLabelPin = GUICtrlCreateLabel("", 10, 10, 150, 20)
GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

;; Ok, instead of defining all the buttons seperately, we are going to try some logic at this.
Dim $x = 0, $y = 0
Dim $guiButton[10] ;; Open a array 10 spaces big to hold the buttons

For $i = 0 to 8 ;; this would be the same as iterating through 1 to 9, but using 0 to 8 is easier to calculate
    $y = Floor($i / 3)
    $x = Mod($i,3)
    ;ConsoleWrite("i = " & $i & @CRLF & "x = " & $x & @CRLF & "y = " & $y & @CRLF & @CRLF) ;; Just to show you that it actually works, since I understand this can be quite intimidating
    $guiButton[$i+1] = GUICtrlCreateButton($i + 1, 10 + ($x * 50), 40 + ($y * 40), 50)
    GUICtrlSetBkColor(-1, 0xCCCCFF)
    GUICtrlSetColor(-1, 0xFFFFFF)
Next

$guiButton[0] = GUICtrlCreateButton("0", 60, 160, 50) ;; Just have to define this one last button, cause it doesn't fit in the 9 button pattern
GUICtrlSetBkColor(-1, 0xCCCCFF)
GUICtrlSetColor(-1, 0xFFFFFF)

GUISetState()

;; What is also a common thing to do, is definite all the functions at the end of the script,
;; also because we are not using on event mode now, we don't need these functions
#cs 
Func _ButtonPress()
    Local $digit
    
    $pass &= GUICtrlRead(@GUI_CtrlId)
    GUICtrlSetData($pin, GUICtrlRead($pin) & "*")
EndFunc

func bye()
    Exit
endfunc
#ce

Dim $inputPass = ""
while 1
    $nMsg = GUIGetMsg() ;; This polls windows for any incoming messages (Ok, well, actually it polls the AutoIt interpreter, but that's another story)
    Switch $nMsg ;; The invaluable switch statement
        Case $GUI_EVENT_CLOSE
            _Exit() ;; Make an exit function, this is useful for clearing up some of the mess you make during programming (close some files, close DLL handles)
                    ;; and it allows to call the exit procedure anywhere in the script
    EndSwitch
    ;; Now we could do 2 things, either write out the Case $guiButton[0], Case $guiButton[1], Case $guiButton[2], or we could again use a For loop, which is what I'll be doing
    For $i = 0 to 9 ;; 10 elements starting at 0
        If $nMsg = $guiButton[$i] Then
            $inputPass &= $i
            GUICtrlSetData( $guiLabelPin, StringLeft("************************", StringLen($inputPass)) )
            ;ConsoleWrite($inputPass & @CRLF) ;; this would show the currently inputted password
            If StringLen($inputPass) = StringLen($sPass) Then
                GUICtrlSetData( $guiLabelPin, "" )
                If $inputPass == $sPass Then ;; To make this case sensitive use a double = character, to make it non-case sensitive use a single = char
                    MsgBox(0x40, "Enter Pin", "Correct.") ;; Use an icon on a messagebox, to make your applications look more professional
                EndIf
                $inputPass = ""
            EndIf
        EndIf
    Next
wend

Func _Exit()
    ;; We could close file handles in here and stuff, but we don't have any so we can just close the script
    Exit
EndFunc

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I know its not that impressive, and probably could be done a lot better, but I'm still proud of myself for it. This is my first script that I wrote without "borrowing" script from other sources that I don't yet understand what it does. I would like to see suggestions for cleaning it up if you have any, I'm sure I made it twice as long as it needs to be. I'm also attempting to make a png gui for it, but I'm still a little while away from understanding all that code. A high five for some one that purdies it up with a png gui, and another high five for someone that explain to me how it works :-P

Edit: I forgot, incase you dont want to go through the code to figure it out, the password is 1234

CODE
#include<guiconstantsEx.au3>

#include <WindowsConstants.au3>

#include <ButtonConstants.au3>

opt("guioneventmode",1)

Dim $digit1, $digit2, $digit3, $digit4

$1 = 0

$2 = 0

$3 = 0

$4 = 0

$maingui = GUICreate("Enter Pin?", 170, 200)

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUISetOnEvent($gui_event_close, "bye")

$1button = GUICtrlCreateButton("1", 10, 40, 50)

GUICtrlSetOnEvent($1button, "onebutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$2button = GUICtrlCreateButton("2", 60, 40, 50)

GUICtrlSetOnEvent($2button, "twobutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$3button = GUICtrlCreateButton("3", 110, 40, 50)

GUICtrlSetOnEvent($3button, "threebutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$4button = GUICtrlCreateButton("4", 10, 80, 50)

GUICtrlSetOnEvent($4button, "fourbutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$5button = GUICtrlCreateButton("5", 60, 80, 50)

GUICtrlSetOnEvent($5button, "fivebutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$6button = GUICtrlCreateButton("6", 110, 80, 50)

GUICtrlSetOnEvent($6button, "sixbutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$7button = GUICtrlCreateButton("7", 10, 120, 50)

GUICtrlSetOnEvent($7button, "sevenbutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$8button = GUICtrlCreateButton("8", 60, 120, 50)

GUICtrlSetOnEvent($8button, "eightbutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$9button = GUICtrlCreateButton("9", 110, 120, 50)

GUICtrlSetOnEvent($9button, "ninebutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

$0button = GUICtrlCreateButton("0", 60, 160, 50)

GUICtrlSetOnEvent($0button, "zerobutton")

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor(-1, 0xFFFFFF)

guisetstate()

func onebutton()

If $1 = 0 then

$1 += 1

$digit1 = "1"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "1"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "1"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "1"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func twobutton()

If $1 = 0 then

$1 += 1

$digit1 = "2"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "2"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "2"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "2"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func threebutton()

If $1 = 0 then

$1 += 1

$digit1 = "3"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "3"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "3"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "3"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func fourbutton()

If $1 = 0 then

$1 += 1

$digit1 = "4"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "4"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "4"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "4"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

If $digit1 = 1 and $digit2 = 2 and $digit3 = 3 and $digit4 = 4 Then

MsgBox(0, "Welcome", "Hello")

Else

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

EndIf

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func fivebutton()

If $1 = 0 then

$1 += 1

$digit1 = "5"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "5"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "5"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "5"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func sixbutton()

If $1 = 0 then

$1 += 1

$digit1 = "6"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "6"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "6"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "6"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func sevenbutton()

If $1 = 0 then

$1 += 1

$digit1 = "7"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "7"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "7"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "7"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

EndIf

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndFunc

func eightbutton()

If $1 = 0 then

$1 += 1

$digit1 = "8"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "8"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "8"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "8"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func ninebutton()

If $1 = 0 then

$1 += 1

$digit1 = "9"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "9"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "9"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "9"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func zerobutton()

If $1 = 0 then

$1 += 1

$digit1 = "0"

GUICtrlCreateLabel("*", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $1 = 1 and $2 = 0 then

$2 += 1

$digit2 = "0"

GUICtrlCreateLabel("*", 30, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

if $2 = 1 and $3 = 0 then

$3 += 1

$digit3 = "0"

GUICtrlCreateLabel("*", 50, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

ElseIf $3 = 1 and $4 = 0 then

$4 += 1

$digit4 = "0"

GUICtrlCreateLabel("*", 70, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

MsgBox(0, "Bad", "No")

$1 -= 1

$2 -= 1

$3 -= 1

$4 -= 1

GUICtrlCreateLabel(" ", 10, 10)

GUICtrlSetFont(-1, 20, 4000, 0, 'comic san serif')

Else

MsgBox(0, "Broken", "You Broke It")

Exit

EndIf

EndIf

EndFunc

func bye()

Exit

endfunc

while 1

sleep(100)

wend

It could be better.. But it is good... Mostly everyone's first couple of scripts are bloated (Except Valik).. Dont worry..It works and that is what matters (most of the time)..

BTW : In your firstpost change [code} [/code} to [codebox} [/codebox}.... It will make it smaller :)

Replace the } with ]

Edited by Konstig

code

Share this post


Link to post
Share on other sites

Thank you all much. I'll have to add my Soup Nazi quote back in for the wrong pins :-P. But I'll have to wait till I have time to understand it all. And I'll have to change the colors cause on this 1853 piece I have at work makes it so you cant really see the stars. Then I'm going to try to make it so its 6 keys long with an accept and a delete button so if someones trying to hack it would have more difficulty not knowing how many digits to guess (of course I'm talking little sister type of hacker, not real hacker I know it would take them less time to hack it then if they knew the code and typed it in). When I get somewhere with that I'll throw it back on here so you can show me the right way to do it :) and @konstig thanks, I was planning on looking up how to do that today, but been ober busy doing work today muttley.


Giggity

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thank you all much. I'll have to add my Soup Nazi quote back in for the wrong pins :-P. But I'll have to wait till I have time to understand it all. And I'll have to change the colors cause on this 1853 piece I have at work makes it so you cant really see the stars. Then I'm going to try to make it so its 6 keys long with an accept and a delete button so if someones trying to hack it would have more difficulty not knowing how many digits to guess (of course I'm talking little sister type of hacker, not real hacker I know it would take them less time to hack it then if they knew the code and typed it in). When I get somewhere with that I'll throw it back on here so you can show me the right way to do it :) and @konstig thanks, I was planning on looking up how to do that today, but been ober busy doing work today muttley.

Try my script, it has variable password lenght.

Just change the $sPass variable.

Edited by Manadar

Share this post


Link to post
Share on other sites

@manadar Thats what I was planning, except I'm gonna try to make the password smaller then the allowed input. Once I have a minute the look at the script and comprehend it.


Giggity

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

@manadar Thats what I was planning, except I'm gonna try to make the password smaller then the allowed input. Once I have a minute the look at the script and comprehend it.

Easy enough, in either script -

While 1
    If StringLen($pass) == $keylen Then
        If $pass == $key Then
            MsgBox(0, "", "Correct")
        EndIf
    ElseIf StringLen($pass) >= 10 Then
        MsgBox(0, "", "Wrong")
        $pass = ""
        GUICtrlSetData($pin, "")
    EndIf
    Sleep(100)
WEnd

This way, you don't get a "Wrong" message and the input is not cleared until you get to 10 characters.

Edited by wraithdu

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