;;; Author: Dejan Kostic ;;; OS: Windows 98SE ;;; AHK Version: 1.0.40 ;;; Date: 27.10.2005 #SingleInstance force #NoTrayIcon Gui,Color, f2f2f2 Gui,add,text,x10 y24 w110,Number of characters: Gui,add,edit,number x130 y20 w120 voutx, ;accepts only numbers Gui,add,checkbox,vSpecZn x10 y50, &Include special characters ;ALT+i activate/deactivate Gui,Font, S9 Cdefault w600, Verdana Gui,add,text,x80 y80 w200,Random password: Gui,Font, S9 Cdefault w500, Arial Gui,add,edit,limit35 x10 y110 w283 vizl, ;limit to 35 characters Gui,Font, S8 Cdefault w600, Verdana Gui,add,button,default x79 y146 w56 glup,&OK Gui,add,button,x153 y146 w83,&Close Gui,show,center w300 h190,Password Generator return lup: gui,submit,nohide if outx= return if outx>35 { MsgBox, Number of characters must not be higher than 35. return } if speczn=1 { GuiControlGet,brzl,,%outx% nt:=ploz_sz(outx) GuiControl,,izl,%nt% gosub,klip } else { GuiControlGet,brzl,,%outx% nt:=ploz(outx) GuiControl,,izl,%nt% gosub,klip } return klip: clipboard= clipboard=%nt% ;save generated password to clipboard ClipWait return ploz_sz(brzl) { spzn=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$`%^&*_+?|}{][~/<>-\=© StringLen, max, spzn Loop { Random, rand, 1, max StringMid, char, spzn, rand, 1 IfNotInString, kennw, %char% { kennw = %kennw%%char% if StrLen(kennw)> brzl break } } return kennw } ploz(brzl) { dozvzn = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 StringLen, max, dozvzn Loop { Random, rand, 1, max StringMid, char, dozvzn, rand, 1 IfNotInString, kennw, %char% { kennw = %kennw%%char% if StrLen(kennw)> brzl break } } return kennw } GuiClose: GuiEscape: ButtonClose: clipboard= ;empty the clipboard ExitAppThe user can determine how many characters the password should have and whether to include special characters or not (default is without special characters). The generated password may contain up to 35 characters and will be copied to the clipboard.
In the script I used the function posted by gogogadgetscott and modified it a bit. Perhaps the whole script could be shorter and simpler, but this is what I came up with.
Constructive feedback, bug reports and improvement suggestions (with code example) are welcome.