Sign in to follow this  
Followers 0

Password compare routine

12 posts in this topic

#1 ·  Posted

I've looked and looked and can't find anything about this or a way to do it.

All I want is to be able to compare two GUI input boxes and when they match have an ICON displayed at the end of the confirm box showing that they do indeed match. All my ideas on how to do it fail miserably.

Is this something that's possible with AutoIT? I've seen it done with vbscript and an hta gui but I can't find anything on how to do it with AutoIT.

Share this post


Link to post
Share on other sites



#2 ·  Posted

gorbisloth,

So what code have you tried that has not worked? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert - Easily convert date/time formats, including the language used
ExtMsgBox ------------- A highly customisable replacement for MsgBox
GUIExtender ----------- Extend and retract multiple sections within a GUI
GUIFrame -------------- Subdivide GUIs into many adjustable frames
GUIListViewEx -------- Insert, delete, move, drag, sort and edit ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ---------------- Scrolling tickertape GUIs
NoFocusLines --------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify -------------------- Small notifications on the edge of the display
Scrollbars -------------- Automatically sized scrollbars with a single command
StringSize -------------- Automatically size controls to fit text
Toast -------------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#3 ·  Posted

Shouldn't be too complicated to do with AutoIt. What have you coded so far?


My UDFs and Tutorials:

UDFs:
Active Directory (2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#4 ·  Posted

Tip:

Take a look at GUICtrlRead()


GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted

This is just the GUI I was using to test this with. It's going to be part of a larger script if I can get it to work. My biggest problem is trying to figure out how to keep this compare routine continuous. I'd like for the icon to change real time as the user types. When the user types in the password in input1 the icon at the end of input2 indicates they don't match. Once the user confirms the password the icon changes. I'd also like it if it would go back to the stop.ico if they change the password fields at some point.

I've tried some if then statements to compare the values, and even some loops, do while and the like.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$PWStatus = "stop.ico"
#Region ### START Koda GUI section ### Form=C:UserswhalmichDesktopScriptsKodaFormsPWConfirm.kxf
$Form1 = GUICreate("Form1", 615, 440, -1, -1)
$Input1 = GUICtrlCreateInput("", 232, 176, 177, 21, 0x0020)
GUICtrlCreateLabel("Password", 96, 176, 50, 17)
$Input2 = GUICtrlCreateInput("", 232, 224, 177, 21, 0x0020)
GUICtrlCreateLabel("Confirm Password", 96, 224, 88, 17)
$Icon1 = GUICtrlCreateIcon($PWStatus, -1, 432, 224, 25, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#6 ·  Posted

Here is something to play with:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$PWStatus = "stop.ico"
#region ### START Koda GUI section ### Form=C:UserswhalmichDesktopScriptsKodaFormsPWConfirm.kxf
$Form1 = GUICreate("Form1", 615, 440, -1, -1)
$Input1 = GUICtrlCreateInput("", 232, 176, 177, 21, 0x0020)
GUICtrlCreateLabel("Password", 96, 176, 50, 17)
$Input2 = GUICtrlCreateInput("", 232, 224, 177, 21, 0x0020)
GUICtrlCreateLabel("Confirm Password", 96, 224, 88, 17)
$Icon1 = GUICtrlCreateIcon($PWStatus, -1, 432, 224, 25, 25)
$hBtnCompare = GUICtrlCreateButton("Compare", 420, 224, 55, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hBtnCompare
            If GUICtrlRead($Input1) <> GUICtrlRead($Input2) Then MsgBox(16, "Passwort Comapre", "Passwords are not equal!")
    EndSwitch
WEnd

My UDFs and Tutorials:

UDFs:
Active Directory (2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#7 ·  Posted

Thanks for the suggestion Water but I was hoping for something that didn't require any interaction from the user. An on the fly comparison if you will.

I think I might have to just go with the error checking when they click the OK box.

Share this post


Link to post
Share on other sites

#8 ·  Posted

Should be possible. But how will you know that the user has finished to enter the 2nd password?


My UDFs and Tutorials:

UDFs:
Active Directory (2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#9 ·  Posted

Should be possible. But how will you know that the user has finished to enter the 2nd password?

Ideally when they both match. That's the thing I can't figure out how to do this as the user types their password and not after they click Ok to go on.

Share this post


Link to post
Share on other sites

#10 ·  Posted

I wouldn't do an automatic compare. Imagine the user wants to type password "12345" into field 1 but misses the last number so the input field contains "1234". When he types "1234" into field 2 your script would assume that the passwords are identical and starts processing.

So the user needs to click a button, leave the input field or press enter to let the script know that he finished to enter the password.


My UDFs and Tutorials:

UDFs:
Active Directory (2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#11 ·  Posted

Here is my whole script. It's intended for imaging Win7 machines. It will display a dialog window to input the computer name, which is prepopulated with the serial number of the pc, then a username and password of a user with domain add privileges. It will then make sure that all the fields have values then it will compare the passwords fields to insure they are identical. After that it kicks off the ghost imaging then once that's done it will update the sysprep file on the freshly imaged machine and restarts. The diskpart button well it wipes the hard drive so don't click on that. This is intended to be run from WinPE.

Now it works perfectly just like this but I wanted the password checking to be real time. It would not kick off any action until the user clicks Ok.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $Sysprep = "C:WindowsPantherunattend.xml"
Global $Flag = 1
Global $sIni = @TempDir & "TAG.ini"
ServiceTag()
#Region ### START Koda GUI section ### Form=c:userswhalmichdesktopscriptskodaformsnathans.kxf
$Form1_ = GUICreate("Ghost Win7", 465, 320, -1, -1)
GUICtrlCreateLabel("Enter Computer Name", 80, 80, 108, 17)
$PCName = GUICtrlCreateInput(IniRead($sIni, 'HW Info', 'Service Tag', ''), 224, 80, 121, 21)
GUICtrlCreateLabel("Enter Username", 80, 120, 80, 17)
$User = GUICtrlCreateInput("", 224, 120, 121, 21)
GUICtrlCreateLabel("Enter Password", 80, 160, 78, 17)
$Password = GUICtrlCreateInput("", 224, 160, 121, 21, 0x0020)
GUICtrlCreateLabel("Confirm Password", 80, 200, 88, 17)
$ConfirmPassword = GUICtrlCreateInput("", 224, 200, 121, 21, 0x0020)
$OKButton = GUICtrlCreateButton("Ok", 96, 240, 75, 25)
$Diskpart = GUICtrlCreateButton("Diskpart", 296, 240, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $OKButton
   GUISetState(@SW_Hide)
   If GUICtrlRead($PCName) = "" or GUICtrlRead($User) = "" or GUICtrlRead($Password) = "" Then
    MsgBox(16, "Error", "You must supply a value for each field!")
    GUISetState(@SW_SHOW)
   Else
    If GUICtrlRead($Password) == GUICtrlRead($ConfirmPassword) Then
     Runwait(@ComSpec & " /c "& "Ghost32.exe -CLONE,mode=restore,src=@MCc,dst=1 -sure",@WindowsDir,@SW_SHOW)
     UpdateSysprep()
     RunWait(@ComSpec & ' /c ' & 'wpeutil Reboot')
     Exit
    Else
     MsgBox(16, "Invalid Password", "The password you typed does not match!")
     GUISetState(@SW_SHOW)
    EndIf
   EndIf
  Case $Diskpart
   DiskpartDrive()
   GUISetState(@SW_SHOW)
EndSwitch
WEnd

Func UpdateSysprep()
While $Flag = 1
$Text = FileRead($Sysprep,FileGetSize($Sysprep))
$Text = StringReplace($Text, "%ComputerName%", GUICtrlRead($PCname))
$Text = StringReplace($Text, "%UserName%", GUICtrlRead($User))
$Text = StringReplace($Text, "%Password%", GUICtrlRead($Password))
FileDelete($Sysprep)
FileWrite($Sysprep,$Text)
FileClose($Sysprep)
$Flag = 0
Wend
EndFunc
Func ServiceTag()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystemProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colItems
        IniWrite($sIni, "HW Info", "Service Tag", $objItem.IdentifyingNumber)
    Next
EndFunc
Func DiskpartDrive()
GUISetState(@SW_HIDE)
$ConfirmDP = MsgBox(4, "Clean Disk 0",  "This will clean disk 0 and create a new partition." & @CRLF & "You should remove any external drives just to be safe."& @CRLF & "" & @CRLF &  "Are you sure you want to continue?")
If $ConfirmDP = 7 Then
Else
  $DPCommands = @TempDir & "dpcommands.txt"
  FileWriteLine($dpcommands, "select disk 0")
  FileWriteLine($dpcommands, "clean")
  FileWriteLine($dpcommands, "create partition primary")
  FileWriteLine($dpcommands, "select partition 1")
  FileWriteLine($dpcommands, "active")
  FileWriteLine($dpcommands, "assign")
  RunWait(@ComSpec & ' /c diskpart /s ' & $DPCommands)
  MsgBox(0, "Complete", "Diskpart Completed.", 5)
  FileDelete($DPCommands)
EndIf
EndFunc

Share this post


Link to post
Share on other sites

#12 ·  Posted

IIRC it is possible to know when the input mark is set into a field and when it is removed. Unfortunately I can't find some example code at the moment.

Will post as soon as I find something.


My UDFs and Tutorials:

UDFs:
Active Directory (2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

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