Jump to content
Sign in to follow this  
Merko

Help with this script, please?

Recommended Posts

Merko

I'm currently working on a script that requires a stub for a secure login system I'll be using $password = "[PASSWORD]" to call the password from another script, on a button click i'd like to display weather the password is right or wrong

$password = "[PASSWORD]"
   Case $msg = $Button_0
     if $userinput = $password Then
                   
    Msgbox(0,"Correct!","Password is correct!")
 Else
                
        MsgBox(0, "Incorrect!","Password is incorrect!")
    EndIf

Basiclly when i press the button no matter what i put in the input box i always get password is incorrect?

Any help wil be highly apreciated, new to autoit!

Thankyoy

Share this post


Link to post
Share on other sites
FireFox

Hi,

Welcome to the autoit forum :)

Please take a look at the helpfile for the GUICtrlRead function.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
l3ill

Or this Quick & Easy Down & Dirty StringCompare Method...

Local $userinput = InputBox("Check PW", "Enter here")
$password = "[PASSWORD]"

$result = StringCompare($password, $userinput, 2)

If $result = 0 Then

    MsgBox(0, "Correct!", "Password is correct!")
Else
    MsgBox(0, "Incorrect!", "Password is incorrect!")
EndIf

Share this post


Link to post
Share on other sites
water

BTW: Please give your threads meaningful titles - because everyone on this forum is looking for help (for his scripts) ;)

So we know what you are asking for without having to read the whole thread.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Merko

 

Or this Quick & Easy Down & Dirty StringCompare Method...

Local $userinput = InputBox("Check PW", "Enter here")
$password = "[PASSWORD]"

$result = StringCompare($password, $userinput, 2)

If $result = 0 Then

    MsgBox(0, "Correct!", "Password is correct!")
Else
    MsgBox(0, "Incorrect!", "Password is incorrect!")
EndIf

Thanks for your reply, is there a way i can stop the form from closing if the password entered is wrong?

Share this post


Link to post
Share on other sites
water

You have to do it in a loop until the password is correct or the suer cancels the input:

Local $password = "[PASSWORD]", $userinput = ""
While 1
    $userinput = InputBox("Check PW", "Enter here")
    If @error <> 0 Then Exit
    $result = StringCompare($password, $userinput, 2) 
    If $result = 0 Then
        MsgBox(0, "Correct!", "Password is correct!")
        ExitLoop
    Else
         MsgBox(0, "Incorrect!", "Password is incorrect!")
    EndIf
WEnd
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
dreamzboy

Try this:

#include <GUIConstantsEx.au3>

GUICreate ("Password Verification", 300, 150)

Local $pw_input, $result, $msg, $verify, $btn
Local $password = "password123" ; Password to verify


GUISetState ()

GUICtrlCreateLabel ("Please enter your password:", 30, 30, 200, 20)
GUICtrlSetFont (-1, 10)
$pw_input = GUICtrlCreateInput ("", 30, 60, 175, 20)
$verify = GUICtrlCreateButton ("Verify", 30, 100, 70, 30)
GUICtrlSetFont (-1, 10)

Do
    $msg = GUIGetMsg ()

    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $verify
            $result = GUICtrlRead ($pw_input)
            If ($result = $password) Then
                MsgBox(64, "Correct!", "Password is correct!")
            Else
                MsgBox(48, "Incorrect!", "Password is incorrect!  Please try again.")
            EndIf
    EndSelect
Until 0

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  

×