Jump to content

Help with this script, please?


Merko
 Share

Go to solution Solved by dreamzboy,

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

 

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?

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Solution

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...