Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Password compare routine


  • Please log in to reply
11 replies to this topic

#1 gorbisloth

gorbisloth

    Seeker

  • Active Members
  • 13 posts

Posted 18 May 2012 - 02:30 PM

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.







#2 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,745 posts

Posted 18 May 2012 - 02:32 PM

gorbisloth,

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

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

#3 water

water

    ?

  • MVPs
  • 15,528 posts

Posted 18 May 2012 - 02:34 PM

Shouldn't be too complicated to do with AutoIt. What have you coded so far?
UDFs:
Active Directory (NEW 2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

#4 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 18 May 2012 - 02:44 PM

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!"

#5 gorbisloth

gorbisloth

    Seeker

  • Active Members
  • 13 posts

Posted 18 May 2012 - 02:44 PM

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


#6 water

water

    ?

  • MVPs
  • 15,528 posts

Posted 18 May 2012 - 02:50 PM

Here is something to play with:
AutoIt         
#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

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

#7 gorbisloth

gorbisloth

    Seeker

  • Active Members
  • 13 posts

Posted 18 May 2012 - 03:03 PM

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.

#8 water

water

    ?

  • MVPs
  • 15,528 posts

Posted 18 May 2012 - 03:04 PM

Should be possible. But how will you know that the user has finished to enter the 2nd password?
UDFs:
Active Directory (NEW 2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

#9 gorbisloth

gorbisloth

    Seeker

  • Active Members
  • 13 posts

Posted 18 May 2012 - 03:13 PM

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.

#10 water

water

    ?

  • MVPs
  • 15,528 posts

Posted 18 May 2012 - 03:19 PM

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.
UDFs:
Active Directory (NEW 2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

#11 gorbisloth

gorbisloth

    Seeker

  • Active Members
  • 13 posts

Posted 18 May 2012 - 03:26 PM

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.

Plain Text         
#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


#12 water

water

    ?

  • MVPs
  • 15,528 posts

Posted 18 May 2012 - 04:00 PM

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.
UDFs:
Active Directory (NEW 2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users