Jump to content
Sign in to follow this  

Setting PW Chars

Recommended Posts


Hello All

So my form I have created uses TONS of fields. Some of which are password fields and need to masked with pw characters like * and whatnot. I got that working already with Styles. But I want to put a button on the form where users can click to turn OFF that function and actually be able to view the passwords.

Below is what one of my Inpute layouts looks like. Should I just have the button re-create all of these fields without the $ES_Password? Or is there someway I can quickly disable/enable that option? I had thought about assigning $ES_Password to a different variable name and then just toggle it = to $ES_Password or just blank to fix the problem. Any suggestions?

Thanks very much for your time.

$fldRow1PW = GUICtrlCreateInput($row1PW,$fldXPW,$fldY,$fldWidth,$fldHeight,$ES_PASSWORD)

Share this post

Link to post
Share on other sites
Richard Robertson

Try GUICtrlSetStyle.

Share this post

Link to post
Share on other sites

Try GUICtrlSetStyle.

Sorry to be a pest, but I need just a little more direction.

If the input field is initialized with the $ES_Password style hiding the characters, how can I get GuiCtrlSetStyle to change that? I tried telling it to set it to "" which did nothing, I tried leaving it blank which errored and I tried setting it to a different style which didn't seem to work either. What would the code be to reverse the pw chars?


Share this post

Link to post
Share on other sites

GuiCtrlSetStyle didn't work for me, so try this work around.

#include <GUIConstants.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("GUI Password", 283, 63, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUICtrlCreateLabel("Enter Password:", 8, 12, 81, 17)
$Input1 = GUICtrlCreateInput("", 96, 8, 177, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Input2 = GUICtrlCreateInput("", 96, 8, 177, 21)
$Button1 = GUICtrlCreateButton("Show Password", 96, 32, 91, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Close", 200, 32, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Form1Close")
#EndRegion ### END Koda GUI section ###

While 1

Func Button1Click() 
    $States = GUICtrlRead($Button1)
    If $States = 'Show Password' Then
        $Password = GUICtrlRead($Input1)
        GUICtrlSetData($Button1, 'Hide Password')
        GUICtrlSetData($Input2, $Password)
        GUICtrlSetState($Input1, $GUI_HIDE + $GUI_DISABLE)
        GUICtrlSetState($Input2, $GUI_SHOW + $GUI_ENABLE)
        $Password = GUICtrlRead($Input2)
        GUICtrlSetData($Button1, 'Show Password')
        GUICtrlSetData($Input1, $Password)
        GUICtrlSetState($Input2, $GUI_HIDE + $GUI_DISABLE)
        GUICtrlSetState($Input1, $GUI_SHOW + $GUI_ENABLE)

Func Form1Close()

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

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
Sign in to follow this