Sign in to follow this  
Followers 0
Hawkwing

End script with password

7 posts in this topic

I am trying to make a script end with a password, but it won't recognize when I press the button.

CODE
Func end ()

GUICreate ("Password", 435, 30, 570, 50)

$input = GUICtrlCreateInput ("", 5, 5, 400, "", $ES_PASSWORD)

$ok = GUICtrlCreateButton ("OK", 410, 03)

GUICtrlSetOnEvent (-1, "guiokpress")

GUISetState (@SW_SHOW)

EndFunc

Func guiokpress ()

If GUICtrlRead ($input) = "password" Then

Exit

Else

ToolTip ("Incorrect password")

EndIf

EndFunc


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites



@pigeek

You forgotten to change the event mode:

Opt("GUIOnEventMode", 1)

Share this post


Link to post
Share on other sites
:) Thanks, I can't believe it was such a simple mistake.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

I finally got it to work.

CODE
Func end ()

Opt ("GUIOnEventMode", 1)

GUICreate ("Password", 435, 30, 570, 50)

$input = GUICtrlCreateInput ("", 5, 5, 400, "", $ES_PASSWORD)

$ok = GUICtrlCreateButton ("OK", 410, 03)

GUICtrlSetOnEvent (-1, "guiokpress")

GUISetState (@SW_SHOW)

EndFunc

Func guiokpress ()

local $input

If GUICtrlRead ($input) = "password" Then ;for some reason you must have the "password" in this line. For instance, if you wanted your password to be "iwantthisscripttoend" you would have to have ($input) = "passwordiwantthisscripttoend.

Exit

Else

ToolTip ("Incorrect password")

EndIf

EndFunc

:)


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites
:) Never mind, I didn't test it thoroughly. Now it accepts anything as the correct password.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

I have this:

CODE
Func end ()

Opt ("GUIOnEventMode", 1)

GUICreate ("Password", 435, 30, 570, 50)

$input = GUICtrlCreateInput ("", 5, 5, 400, "", $ES_PASSWORD)

$ok = GUICtrlCreateButton ("OK", 410, 03)

GUICtrlSetOnEvent (-1, "guiokpress")

GUISetState (@SW_SHOW)

EndFunc

Func guiokpress ()

If GUICtrlRead ($input) = "password" Then

Exit

Else

ToolTip ("Incorrect password")

EndIf

EndFunc

but when I press OK it says that I used a variable that wasn't stated.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

pigeek

Make a small and working example, which duplicate the problem.

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