Graeme

Entering passwords

5 posts in this topic

I have code to enter password using the setting $ES_PASSWORD. It seems that with this setting you can't enter more than the letters that fill box. Can anyone tell me how to enter more characters?

GUICreate("Password Test",500,200)
    $Input = GUICtrlCreateInput("Password",10,20,40,50,$ES_PASSWORD)
GUISetState(@SW_SHOW,"Password Test")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE,"Password Test")
            ExitLoop
    EndSwitch
WEnd
If GUICtrlRead($Input) <> "" Then MsgBox(0,GUICtrlRead($Input),"Done")

With this code you can only enter 4 characters of password.

Share this post


Link to post
Share on other sites



With using $ES_Password you have dropped all other default style values. You need to add them using something like this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("Password Test", 500, 200)
$Input = GUICtrlCreateInput("Password", 10, 20, 40, 20, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
$OK = GUICtrlCreateButton("OK", 60, 20, 40, 20)
GUISetState(@SW_SHOW, "Password Test")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, "Password Test")
            ExitLoop
        Case $OK
            MsgBox(0, "Password", "Password has " & StringLen(GUICtrlRead($Input)) & " characters!")
    EndSwitch
WEnd

BTW: When posting code, please post a fully working script with all needed includes etc. Makes testing much easier und faster ;)

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-03 - Version 1.2.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (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

or

BitOR($ES_PASSWORD, $GUI_SS_DEFAULT_INPUT)

 

1 person likes this

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Even better and more flexible :)

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-03 - Version 1.2.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (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

Thanks to both of you! Sorry about missing the includes.:>

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

  • Similar Content

    • 31290
      By 31290
      Hi Guys, 
      Hope you're fine today!
      I'd like to create a small GUI that, when clicking a button, the password set in the GUICtrlCreateInput is revealed and when the click is released, the password is hidden again. W8/10 style in fact...
      Here's what I have so far:
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) f_RemedyUpdate() While 1 Sleep(10) Wend Func f_RemedyUpdate() $gMailCreds = GUICreate("SEE CHECKLISTS", 300, 140) GUISetBkColor($Color_White) GUISetFont(8.5, 700, 0) GUICtrlCreateLabel("Password required for your account" , 5, 10) GUICtrlCreateLabel("Your Password:", 10, 70, 100, 30) $g_PassInput = GUICtrlCreateInput("", 110, 66, 150, 20, $ES_PASSWORD) GUICtrlSetColor(-1, 0x800080) $g_ShowPassButton = GuiCtrlCreateButton ("", 270, 67, 16, 16, $BS_ICON) GUICtrlSetImage(-1, "C:\eye.ico") GuiCtrlSetOnEvent ($g_ShowPassButton, "f_ShowPassword") $g_SubmitBtn = GUICtrlCreateButton ("Submit", 120, 100, -1, -1, $BS_DEFPUSHBUTTON) GUICtrlSetOnEvent(-1, "f_SendMail") GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") GUISetState(@SW_SHOW) EndFunc Func f_ShowPassword() $s_PWD = GuiCtrlRead ($g_PassInput) If $s_PWD = "" Then Msgbox (64, "Your password", "You did not type any password") Else Msgbox (64, "Your Password", "You typed --> " & $s_PWD & " <-- as password.") EndIf EndFunc I've enclosed the small ico file I'm using 
      Thanks in advance for any help provided
      -31290
       
      eye.ico
    • Jemboy
      By Jemboy
      Hi,
      I am trying to log into live.com using AutoIt.
      There are several examples, but none of them work with the current webpage.
      This is my code (because the username and password are not valid ;-) , I comment the "button click" out.):
      #include <IE.au3> Local $oIE = _IECreate("live.com") _IELoadWait ($oIE) _IELinkClickByText($oIE, "Sign in") $o_form = _IEFormGetObjByName ($oIE, "f1") $o_login = _IEFormElementGetObjByName ($o_form, "loginfmt") $o_password = _IEFormElementGetObjByName ($o_form, "passwd") $o_signin = _IEFormElementGetObjByName ($o_form, "idSIButton9") $username = "test@hotmail.com" $password = "testpassword" _IEAction ($o_login, "focus") _IEFormElementSetValue ($o_login, $username) _IEFormElementSetValue ($o_password, $password) ;_IEAction ($o_signin, "click") When I run the code I get the following:

      The value being set is garbeled with "PlaceholderText".
      Because of this, the username and password are invalid.
      Here screenhot of the placeholders text:

      When you start typing in one of the fields, the placeholder text is automatically deleted.
      When you set a value it stays.
      I found a workaround, to set focus on the element and send the username as an keyboard input to the field,
      but I would like a clean solution based on variables.
      So, does anyone now how to do this?
       
       
       
       
    • clariceo0
      By clariceo0
      Recently, I am interested to build a windows app to reset Windows login password as a side off project. I am still a newbie in programming so i am not able to build the app from scratch. Is there any open source  project i could learn from on this?
    • Mecano
      By Mecano
      Hallo members,
      Looking for the right regex for password validation, the password must be eight characters long including at least 1 number and includes both lower and uppercase letters and at least 1 special character.
      € , £ and letters with umlauts, accents, etc. are not allowed.
      I have made a test gui with two different validations, this is just for testing purposes, but is this right way to do it?
      '((?=.*\d)(?=.*[A-Z])(?=.*\W).{8,8})' and
      '([A-Za-z: ]+\$([A-Z0-9]+)([\s]*[A-Za-z: ]+\$([A-Z0-9]+)){0,2})'  
      The test GUI
      #NoTrayIcon #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Local $GUI, $Password, $Button1, $Button2 $GUI = GUICreate("Form1", 412, 261, 192, 124) $Password = GUICtrlCreateInput("", 96, 32, 193, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, False, "8 characters") GUICtrlSetLimit(-1, 8, 8) $Button1 = GUICtrlCreateButton("Export", 97, 77, 193, 25) $Button2 = GUICtrlCreateButton("Import", 97, 123, 193, 25) GUISetState(@SW_SHOW) While 1 Local $StringPassw = GUICtrlRead($Password) Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Export If $StringPassw = "" Then MsgBox(16, "Error!", "Password can not be empty") GUICtrlSetState($Password, $GUI_FOCUS) ; regex for testing, the password must be eight characters including one uppercase letter, one special character and alphanumeric characters. ElseIf StringRegExp($StringPassw, '((?=.*\d)(?=.*[A-Z])(?=.*\W).{8,8})') Then MsgBox(0, "Strong", "Password is 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") ; Debug ; Export() GUICtrlSetState($Button1, $GUI_DISABLE) Else MsgBox(64, "Password is not strong!", "Re-type password, Password must be 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") GUICtrlSetData($Password, "") EndIf Case $Button2 ; Import If $StringPassw = "" Then MsgBox(16, "Error!", "Password can not be empty") ; another regex for testing GUICtrlSetState($Password, $GUI_FOCUS) ElseIf StringRegExp($StringPassw, '([A-Za-z: ]+\$([A-Z0-9]+)([\s]*[A-Za-z: ]+\$([A-Z0-9]+)){0,2})') Then MsgBox(0, "Strong", "Password is 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") ; Debug ; Import() GUICtrlSetState($Button2, $GUI_DISABLE) Else MsgBox(64, "Password is not strong!", "Re-type password, Password must be 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") GUICtrlSetData($Password, "") EndIf EndSwitch WEnd  
      searched the forum, but good not find a good example
      Edit;
      the password must be eight characters long including at least 1 number and includes both lower and uppercase letters and at least 1 special character.
      € , £ and letters with umlauts, accents, etc. are not allowed.
       

      I need only a single regular expression
      Thanks in advance
       
       
    • 31290
      By 31290
      Hi everyone, 
      I'm building some script that will encrypt some user password and store it in an ini file.
      I'd like to recall the password in a putty session but I can't figure out how to decrypt it:

      So far, I have:
      Global $Images = "C:\SAC_IS\ATL_Laptop\Resources\Images\" Global $WorkingDir = "C:\SAC_IS\Switches_Toolbox\" Global $Settings = $WorkingDir & "\Settings.ini" DirCreate ($WorkingDir) _FirstRun() While 1 Sleep(10) WEnd Func _FirstRun() If FileExists ("C:\SAC_IS\Switches_Toolbox\Settings.ini") Then _LoginfoGUI() Else MsgBox (64, "PUTTY EXECUTABLE", "First, select PUTTY.EXE path") Global $PuttyPath = FileOpenDialog("Please indicate putty.exe path", @HomeDrive, "exe (*.exe)") _LoginfoGUI() If @Error Then Global $Error = MsgBox(21, "Error!", "Can't find PUTTY.EXE!"& @CRLF & "Click Retry or Cancel to Quit") If $Error = $IDRETRY Then _FirstRun() Else _Exit() EndIf Else FileInstall ("C:\Users\h74033\Desktop\Scirpts\Switches\Settings.ini", $WorkingDir & "\Settings.ini", 1) IniWrite ($Settings, "Putty", "Path", $PuttyPath) EndIf EndIf ; SwitchesToolboxGui() Endfunc Func _Exit() Exit EndFunc Func _LoginfoGUI() Global $LoginfoGUI = GUICreate("Switches Toolbox Configuration", 300, 300, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $LoginfoGUI) GUICtrlCreatePic ($Images & "\SAClogo.jpg", 30, 10, 240, 80) GUISetBkColor ($Color_White) GUICtrlCreateLabel("-- SWITCHES TOOLBOX --", 85, 100, 150, 25) GUICtrlSetFont (-1, 8.5, 700, 0) GUICtrlCreateLabel("Please provide required information:", 10, 130, 250, 25) GUICtrlCreateLabel("-Global ID:", 10, 170, 60, 30) GUICtrlSetFont (-1, 8.5, 700, 0) GUICtrlCreateLabel("-Password:", 10, 210, 70, 30) GUICtrlSetFont (-1, 8.5, 700, 0) Global $GIDInput = GUICtrlCreateInput("", 90, 168, 80, 20) Global $PassInput = GUICtrlCreateInput("", 90, 205, 150, 20, $ES_PASSWORD) GUICtrlCreateButton ("Submit", 100, 245, 100, 25) GUICtrlSetOnEvent(-1, "_Submit") GUISetState(@SW_SHOW) EndFunc Func _Submit() Global $GID = GuiCtrlRead($GIDInput) Global $EncryptedPwd = _Crypt_HashData (GuiCtrlRead($PassInput), $CALG_MD2) IniWrite ($Settings, "Username", "Gid", $Gid) IniWrite ($Settings, "Encryption", "Password", $EncryptedPwd) ;MsgBox(0, "re", $EncryptedPwd) EndFunc How can I achieve that please?
      Thanks in advance