Sign in to follow this  
Followers 0
t1g3r

Please Help Me

5 posts in this topic

Hi Everyone, this may seem like a dumb question but:

Here is what i have so far.

#include <GUIConstants.au3>

GUICreate("Security", 200, 100)

GUICtrlCreateLabel("Enter Password!", 60, 10)

GUICtrlCreateButton("OK", 80, 60, 40)

GUISetState(@SW_SHOW)

GUICtrlCreateInput("", 60, 35, 80, 20, $ES_PASSWORD)

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

Not much I no but im just getting started with this GUI stuff, my question is I want to be able to click the OK button and if the password is correct i then want it to run my script. Can somebody please help me.

Thank U.

Share this post


Link to post
Share on other sites



Not good but may point you in right direction

#include <GUIConstants.au3>
$pass = 1234
GUICreate("Security", 200, 100)
GUICtrlCreateLabel("Enter Password!", 60, 10)
$button1 = GUICtrlCreateButton("OK", 80, 60, 40)
GUISetState(@SW_SHOW)
$pass1 = GUICtrlCreateInput("", 60, 35, 80, 20, $ES_PASSWORD)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
    Exit
Case $msg = $button1
    If GUICtrlRead($pass1) = $pass Then
        Run("notepad")
    Else
        MsgBox(0,"","Try Again")
        EndIf
Case Else
    ;;;;;;;
    EndSelect
WEnd


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Not good but may point you in right direction

#include <GUIConstants.au3>
$pass = 1234
GUICreate("Security", 200, 100)
GUICtrlCreateLabel("Enter Password!", 60, 10)
$button1 = GUICtrlCreateButton("OK", 80, 60, 40)
GUISetState(@SW_SHOW)
$pass1 = GUICtrlCreateInput("", 60, 35, 80, 20, $ES_PASSWORD)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
    Exit
Case $msg = $button1
    If GUICtrlRead($pass1) = $pass Then
        Run("notepad")
    Else
        MsgBox(0,"","Try Again")
        EndIf
Case Else
;;;;;;;
    EndSelect
WEnd

Works Great, thanks alot for your help.

Share this post


Link to post
Share on other sites

Ok just one more question to ask.

1. I have my script which runs until i terminate it with a hotkey.

2. I also have a GUI which (when the correct password is entered) will run a program.

My Question is can i add the GUI to my script and run it as one but the rest of the script will only continue if the correct password is entered.

Many thanks for any help given.

Share this post


Link to post
Share on other sites

#include <guiconstants.au3>

Global $Password = '1234AABB', $PASSWORDCHECK = 0
CHECKPASSWORD()

While 1
;MY SCRIPT CALLING FUNCTIONS DOING WHATEVER
    If $PASSWORDCHECK = 1 Then
        MsgBox(0, 'TEST', 'PASSWORD WAS CORRECT, YOU MAY CONTINUE'); YOU COULD PUT YOUR RUN FUNCTION HERE SINCE THE PASSWORD IS CORRECT
        $PASSWORDCHECK = 0
    EndIf
WEnd

Func CHECKPASSWORD()
$PASSWORD_GUI = GUICreate('PASSWORD', 200, 80)
$PASS_INPUT = GUICtrlCreateInput('', 10, 10, 180, 20, $ES_PASSWORD)
$PASS_SUBMIT = GUICtrlCreateButton('SUBMIT', 45, 35, 50, 30)
$PASS_CANCEL = GUICtrlCreateButton('CANCEL', 105, 35, 50, 30)

GUISetState()

While 1
    $PASSMSG = GUIGetMsg()
    Select
        Case $PASSMSG = $GUI_EVENT_CLOSE Or $PASSMSG = $PASS_CANCEL
            If MsgBox(36, 'CONFIRM', 'IF YOU CLICK YES YOU WILL BE EXITED COMPLTETELY' & @CRLF & 'ARE YOU SURE YOU WANT TO EXIT?') == 6 Then
                Exit
            EndIf
        Case $PASSMSG = $PASS_SUBMIT
            If GUICtrlRead($PASS_INPUT) <> '' Then
                IF GUICtrlRead($PASS_INPUT) = $Password Then
                    ExitLoop
                Else
                    MsgBox(64, 'ERROR', 'INCORRECT PASSWORD, PLEASE CHECK AND TRY AGAIN')
                EndIf
            Else
                MsgBox(64, 'ERROR', 'THERE IS NO PASSWORD FILLED IN')
            EndIf
    EndSelect
WEnd
GUIDelete($PASSWORD_GUI)
$PASSWORDCHECK = 1
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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