;****************************************************************************** ;* Script : PwdGen.au3 ;* ;* Description : Password Generator ;* ;* Language : Auto-It v3 - http://www.autoitscript.com/autoit3/ ;****************************************************************************** ;* Program History: ;* ;* Version : 1.0.0 ;* Author : Craig H. Rettig ;* Date : 31 May 2007 ;* Notes : Initial release ;****************************************************************************** ;* This program is free software. It comes without any warranty, to ;* the extent permitted by applicable law. You can redistribute it ;* and/or modify it under the terms of the Do What The F*** You Want ;* To Public License, Version 2, as published by Sam Hocevar. See ;* http://sam.zoy.org/wtfpl/COPYING for more details. ;****************************************************************************** #include ; Customization variables Global $AppName = "Craig's Password Generator" Global $AppCo = "Craig H. Rettig" Global $AppSite = "http://www.bitbucketheaven.com/software/craigs-password-generator/" Global $AppEmail = "support@bitbucketheaven.com" Global $AppVersion = "1.0.0" Global $iniFile = "" ; Other globals ; Set path to .INI file If @compiled = 1 Then $iniFile = StringReplace(@AutoItExe, ".exe", ".ini") Else $iniFile = StringReplace(@ScriptFullPath, ".au3", ".ini") EndIf Func GetRndChar($strType) Local $strLetters Select Case $strType = "c" ; consonant If GUICtrlRead($chkMixed) = $GUI_CHECKED Then $strLetters = "bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ" Else $strLetters = "bcdfghjkmnpqrstvwxyz" EndIf Return StringMid($strLetters, Random(1, StringLen($strLetters)), 1) Case $strType = "v" ; vowel If GUICtrlRead($chkMixed) = $GUI_CHECKED Then $strLetters = "aeiouAEIU" Else $strLetters = "aeiou" EndIf Return StringMid($strLetters, Random(1, StringLen($strLetters)), 1) Case Else ; "d" - digit Return String(Random(2, 9, 1)) EndSelect EndFunc Func NewPwd() Local $strPatt, $strPass, $intLength, $x $intLength = Int(GUICtrlRead($cmbLength)) If $intLength < 6 Or $intLength > 12 Then MsgBox(48, "Password Length Too Long", "Please only use a password Length between 6-12.") Else $strPass = "" Select Case $intLength = 6 $strPatt = "cvcddd" Case $intLength = 7 $strPatt = "cvcdcvc" Case $intLength = 8 $strPatt = "cvcddcvc" Case $intLength = 9 $strPatt = "cvcdddcvc" Case $intLength = 10 $strPatt = "cvcddcvcdd" Case $intLength = 11 $strPatt = "cvcdddcvcdd" Case Else ; (12) $strPatt = "cvcdddcvcddd" EndSelect For $x = 1 To $intLength $strPass = $strPass & GetRndChar(StringMid($strPatt, $x, 1)) Next GUICtrlSetData($txtPwd, $strPass) EndIf EndFunc ;****************************************************************************** ;****************************** CREATE THE GUI ****************************** ;****************************************************************************** ; Window GuiCreate($AppName, 250, 130, -1, -1, BitOr($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GuiSetIcon("F:\Documents\Code\Auto-It3\secur08.ico", 0) ; File Menu $mnuFile = GuiCtrlCreateMenu("&File") $mnuFileExit = GUICtrlCreateMenuitem("E&xit", $mnuFile) ; Help Menu $mnuHelp = GuiCtrlCreateMenu("&Help") $mnuHelpWebSite = GUICtrlCreateMenuitem("Application &Home Page", $mnuHelp) $mnuHelpLine = GUICtrlCreateMenuitem("", $mnuHelp) $mnuHelpAbout = GUICtrlCreateMenuitem("&About " & $AppName & "...", $mnuHelp) ; Options $lblLength = GUICtrlCreateLabel("Length:", 10, 9, 50, 20) GUICtrlSetFont($lblLength, 10, 400, 1, "Arial") $cmbLength = GUICtrlCreateInput("8", 60, 8, 50, 22, $ES_NUMBER) $udLength = GUICtrlSetLimit(GUICtrlCreateUpdown($cmbLength), 12, 6) GUICtrlSetFont($cmbLength, 10, 400, 1, "Arial") $chkMixed = GUICtrlCreateCheckbox("Mixed Case", 150, 10, 90, 20) GUICtrlSetFont($chkMixed, 10, 400, 1, "Arial") ; Password $txtPwd = GuiCtrlCreateEdit("", 10, 40, 230, 25, $ES_AUTOHSCROLL + $ES_CENTER) GUICtrlSetFont($txtPwd, 12, 400, 1, "Courier New") ; Buttons $cmdNewPwd = GUICtrlCreateButton("&New Password", 50, 75, 150, 30, $BS_CENTER) GUICtrlSetFont($cmdNewPwd, 10, 400, 1, "Arial") If FileExists($iniFile) Then If IniRead($iniFile, "Settings", "Mixed", 4) = 1 Then GUICtrlSetState($chkMixed, $GUI_CHECKED) EndIf GUICtrlSetData($cmbLength, IniRead($iniFile, "Settings", "Length", 8)) EndIf NewPwd() GUICtrlSetState ($cmdNewPwd, $GUI_FOCUS) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $mnuHelpWebSite ; Help->Author's Home Page Run(@COMSPEC & " /c Start " & $AppSite, @SystemDir, @SW_MINIMIZE) Case $msg = $mnuHelpAbout ; Help->About (App name)... MsgBox(64, "About " & $AppName, $AppName & " " & $AppVersion & @CRLF & @CRLF & $AppSite & @CRLF & @CRLF & "This program is free software. It comes without any warranty, to" & @CRLF & "the extent permitted by applicable law. You can redistribute it" & @CRLF & "and/or modify it under the terms of the Do What The F*** You Want" & @CRLF & "To Public License, Version 2, as published by Sam Hocevar. See" & @CRLF & "http://sam.zoy.org/wtfpl/COPYING for more details.") Case $msg = $cmdNewPwd ; New Password button NewPwd() Case $msg = $GUI_EVENT_CLOSE ; Closed through Windows icon or keystroke ExitLoop Case $msg = $mnuFileExit ; File->Exit ExitLoop EndSelect WEnd ; Closes the GUI and terminates the app. IniWrite($iniFile, "Settings", "Mixed", GUICtrlRead($chkMixed)) IniWrite($iniFile, "Settings", "Length", GUICtrlRead($cmbLength)) GUIDelete() Exit