DreamVB Posted September 12, 2014 Share Posted September 12, 2014 (edited) hi, this is my password generator this is also my first GUI script here are some details of the script. Create passwords, Uppercase, LowerCase, Digits Only, Mixed, Mixed+Special chars Create Any number of password with any length. Easy to copy passwords to the clipboard. Well that's about it here is the script Your free to use the script as you wish. expandcollapse popup;A password generator application ;By Ben Jones, Aka DreamVB #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;Appliaction title message Const $Title = "Easy Password Generator" _ & @CRLF & " The easy way to make passwords." ;Create GUI Conponents $Form1 = GUICreate("Welcome", 337, 399, -1, -1) $lblPwsCount = GUICtrlCreateLabel("Number of passwords to make:", 8, 85, 150, 17) $txtPwsCount = GUICtrlCreateInput("8", 8, 101, 41, 21) $lblPwsLen = GUICtrlCreateLabel("How long should each password be?", 8, 133, 179, 17) $txtPwsLen = GUICtrlCreateInput("8", 8, 149, 41, 21) $lblPwsFmt = GUICtrlCreateLabel("Password Format:", 8, 181, 88, 17) $txtPasswords = GUICtrlCreateEdit("", 8, 251, 241, 137) GUICtrlSetData(-1, "") $cmdCopy = GUICtrlCreateButton("&Copy", 257, 283, 71, 25) $cmdAbout = GUICtrlCreateButton("&About", 257, 331, 71, 25) $cmdExit = GUICtrlCreateButton("E&xit", 258, 363, 71, 25) $cmdGen = GUICtrlCreateButton("Generate", 257, 252, 71, 25) $lblTitle = GUICtrlCreateLabel($Title, 22, 7, 290, 71, $SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Comic Sans MS") GUICtrlSetColor(-1, 0xFFFF00) GUICtrlSetBkColor(-1, 0x0000FF) GUISetBkColor(0xFFFFFF) $cboFmt = GUICtrlCreateCombo("", 8, 200, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Alpha Uppercase|Alpha Lowercase|Digits Only|Mixed Alpha/Digit|Mixed+Special", "Alpha Uppercase") $lblPasswrds = GUICtrlCreateLabel("Passwords:", 8, 230, 58, 17) GUISetState(@SW_SHOW) Local $pCount Local $LineCount Local $len Local $i Local $RetBuff Local $PwsFmt While 1 ;Get message $nMsg = GUIGetMsg() ;Deal with the messages. Switch $nMsg Case $GUI_EVENT_CLOSE, $cmdExit ExitLoop Case $GUI_EVENT_CLOSE, $cmdAbout MsgBox(64, "About", "Easy Password Generator" _ & @CRLF & "Version 1.1" _ & @CRLF & "By DreamVB" _ & @CRLF & @CRLF & "Designed in AutoIt") Case $GUI_EVENT_CLOSE, $cmdCopy ;Copy text to clipabord. ;Get length of the textbox $LineCount = _GUICtrlEdit_GetLineCount($txtPasswords) ;Check for text If ($LineCount > 0) Then ;Add text header For $i = 0 To $LineCount - 1 If ($i < $LineCount) Then $RetBuff = $RetBuff & _GUICtrlEdit_GetLine($txtPasswords, $i) & @CRLF EndIf Next ;Put text on clipboard. ClipPut($RetBuff) ;Clear up $RetBuff = "" $i = 0 EndIf Case $GUI_EVENT_CLOSE, $cboFmt ;Get password format. $PwsFmt = _GUICtrlComboBox_GetCurSel($cboFmt) Case $GUI_EVENT_CLOSE, $cmdGen ;Get number of passwords to make. $pCount = _GUICtrlEdit_GetLine($txtPwsCount, 2) ;Get the length of the password to make. $len = _GUICtrlEdit_GetLine($txtPwsLen, 2) ;Check for vaild password count. If Not StringIsDigit($pCount) Or $pCount = 0 Then MsgBox(48, "Error", "Invaild password count." & @CRLF & "Program will now exit.") ElseIf Not StringIsDigit($len) Or $len = 0 Then MsgBox(48, "Error", "Invaild password length" & @CRLF & "Program will now exit.") ControlFocus("","",$txtPwsLen) Else ;Header $RetBuff = $RetBuff & "+----------------------------+" & @CRLF $RetBuff = $RetBuff & "+ Your Passwords +" & @CRLF $RetBuff = $RetBuff & "+----------------------------+" & @CRLF ;Generate the passwords. For $i = 0 To $pCount - 1 If ($i < $pCount) Then ;Create password $RetBuff = $RetBuff & RandomPassword($len, $PwsFmt) & @CRLF EndIf Next ;Footer $RetBuff = $RetBuff & @CRLF & "Created by Easy Password Generator" ;Set text box with generated passwords. _GUICtrlEdit_SetText($txtPasswords, $RetBuff) $RetBuff = "" EndIf EndSwitch WEnd If GUIDelete($Form1) <> 1 Then MsgBox(16, "Error", "There was an error while exsiting..") Exit EndIf ;This function makes the random passwords Func RandomPassword($Length, $Fmt = 0) Local $buff Local $i Local $n Local Const $Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Local Const $ADigits = "0123456789" Local Const $Special = "!#$%&'()*+,-./:;<=>?@[\]^_`{|}~" ;Password include file Local $pwsMask = "" ;Do password formatting Select Case $Fmt = 0 $pwsMask = $Alpha Case $Fmt = 1 $pwsMask = StringLower($Alpha) Case $Fmt = 2 $pwsMask = $ADigits Case $Fmt = 3 $pwsMask = $Alpha & StringLower($Alpha) & $ADigits Case $Fmt $pwsMask = $Alpha & StringLower($Alpha) & $ADigits & $Special EndSelect ;This creates the random password. For $i = 1 To $Length ;Pick a random chat between 1 and the pwsMask Length $n = Int(Random(1, StringLen($pwsMask))) ;Concat each chat that has been picked out of pwsMask to $buff $buff = $buff & StringMid($pwsMask, $n, 1) Next Return $buff EndFunc ;==>RandomPassword Edited September 12, 2014 by DreamVB izibitzi and zoel 2 On Error Resume Pulling Hair Out. Link to comment Share on other sites More sharing options...
AoRaToS Posted September 12, 2014 Share Posted September 12, 2014 Nice and simple s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3 Link to comment Share on other sites More sharing options...
DreamVB Posted September 12, 2014 Author Share Posted September 12, 2014 Nice and simple Thanks glad you like it. I am trying to think of some new ideas to put into. so check back for new versions. On Error Resume Pulling Hair Out. Link to comment Share on other sites More sharing options...
lorenkinzel Posted September 13, 2014 Share Posted September 13, 2014 Works nicely & is pretty cool if you need to hand out several passwords per day. "I am trying to think of some new ideas to put into" Now a really secure passphrase that is easy to rememberize would be something like: Get1Coffee@7-11&DrinkItUp ScoreA_cappuccinoFrom*Bucks&DoTheAmBuzz sHe_hEarts_mE_&_i_dOnt_gIve_a_cArp How to do this in a program I have no clue. Simply tossing out "new ideas". Link to comment Share on other sites More sharing options...
qwert Posted September 13, 2014 Share Posted September 13, 2014 @DreamVB, Many sites exclude the use of certain special characters ... like punctuation. How about a feature (checkboxes?) to allow easy selection of the set of special characters? Link to comment Share on other sites More sharing options...
DreamVB Posted September 13, 2014 Author Share Posted September 13, 2014 @DreamVB, Many sites exclude the use of certain special characters ... like punctuation. How about a feature (checkboxes?) to allow easy selection of the set of special characters? Thanks that is a good idea, I was thinking of putting in a textbox for the special characters that way as you say people can then add there own. On Error Resume Pulling Hair Out. Link to comment Share on other sites More sharing options...
Pollycom Posted May 22, 2016 Share Posted May 22, 2016 Any one please help convert this script from powershell to AutoIT function Get-RandomPassword { param( $length = 8, $characters = 'abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789!"§$%&/()=?*+#_' ) # select random characters $random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length } # output random pwd $private:ofs="" [String]$characters[$random] } $caps = Get-RandomPassword -length 4 -characters 'AbCdEf' $lows = Get-RandomPassword -length 4 -characters '12345678' $nums = [char[]] [string[]] (0..9) $first = Get-Random -Minimum 1 -Maximum 2 $second = Get-Random -Minimum 1 -Maximum (8-$first) $third = 8-$first-$second $ofs = "" $CC='$' $pass = [string](@($caps | Get-Random -Count $first) + @($CC) + @($lows | Get-Random -Count $second) ) Thanks, Tri Link to comment Share on other sites More sharing options...
water Posted May 22, 2016 Share Posted May 22, 2016 Welcome to AutoIt and the forum! Can you please post what you have tried so far? We do not spoon-feed users here, we teach them to code Student_coder 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Joro Posted February 7, 2018 Share Posted February 7, 2018 Very nice DreamVB! Simple too. I have noticed, when using it, that it does not give the number 9 and the letter "z" in a generated password. So the last character of the three constants $Alpha, $ADigits and $Special. I think there's a flaw in line 152 of function RandomPassword. It says: $n = Int(Random(1, StringLen($pwsMask))) When I change it to: $n = Int(Random(1, StringLen($pwsMask)+1)) it will give the 9 and the "z". (I added "+1" after "StringLen($pwsMask)" Maybe there's a better way to solve it, but I just wanted it to mention. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now