Jump to content
Sign in to follow this  

How to change $ES_PASSWORD style of an Input?

Recommended Posts


Hello everyone,

I wonder if there's a way to change the $ES_PASSWORD style of an Input without having to delete, and re-create it? I did try to use the GUICtrlSetStyle() function, but it doesn't seem to work. ;)

For the convinience, I'll put what I have here. So basically, what I want is that the $ES_PASSWORD style of $Input2 will change in according with the user checking the checkbox. I can do it by deleting and re-creating the $Input2. But this seems not very covenient. Is there some other way to work around?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\Travian Log-In.kxf
Global $Blank[5]

$Form1 = GUICreate("Log-in Form", 633, 130, -1, -1)
$Label1 = GUICtrlCreateLabel("Please enter your log-in information below. If you forget your password, please click on the Forget Password button.", 8, 8, 545, 17)
$Label2 = GUICtrlCreateLabel("Username:", 152, 40, 55, 17)
$Label3 = GUICtrlCreateLabel("Pass:", 152, 64, 30, 17)
$Input1 = GUICtrlCreateInput("Please enter your username here", 208, 37, 241, 21)
GUICtrlSetFont(-1, 8, 400, 2, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808080)
$Input2 = GUICtrlCreateInput("", 208, 61, 241, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
$Button1 = GUICtrlCreateButton("Log In", 136, 96, 113, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Forget Password", 264, 96, 113, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Exit", 392, 96, 113, 25, $WS_GROUP)
$Checkbox1 = GUICtrlCreateCheckbox("Show Password", 472, 64, 97, 17)
For $Temp = 0 To 4
    $Blank[$Temp] = 0
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button3
        Case $Checkbox1

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0xFFFF)
    $hCtrl = $lParam

    If $nID = $Input1 Then
        If $nNotifyCode = $EN_SETFOCUS Then
            If $Blank[0] = 0 Then
                GUICtrlSetData($Input1, "")
                GUICtrlSetFont($Input1, 8, 400, 0, "MS Sans Serif")
                GUICtrlSetColor($Input1, 0x000000)
            If $nNotifyCode = $EN_KILLFOCUS Then
                $a = GUICtrlRead($Input1)
                If $a <> "" And $a <> "Please enter your username here" Then
                    $Blank[0] = 1
                    $Blank[0] = 0
                    GUICtrlSetData($Input1, "Please enter your username here")
                    GUICtrlSetFont($Input1, 8, 400, 2, "MS Sans Serif")
                    GUICtrlSetColor($Input1, 0x808080)


Func CheckCheckBox()
    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
        $a = GUICtrlRead($Input2)
        $Input2 = GUICtrlCreateInput($a, 208, 61, 241, 21)
        $a = GUICtrlRead($Input2)
        $Input2 = GUICtrlCreateInput($a, 208, 61, 241, 21, $ES_PASSWORD)

Thanks everyone in advance, :)

Edited by eEniquEe

Share this post

Link to post
Share on other sites


Search (that little box at top right ;)) threw up this which should help you. :)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

OMG... I feel ssssssoooooo guilty for not noticing that Search Box. :D :D :D :D I'm sorry... :);)

Thank you very very much, that solves it. :D I'll search carefully before creating new thread from now on, I promise. ;)

Share this post

Link to post
Share on other sites

You might also want to check out if you want neater and more re-usable code that doesn't throw focus onto the input :)

Share this post

Link to post
Share on other sites

Sorry for my late respond. Thank you very much smartee. Your way is very elegant, and neat. :)

Thanks, ;)

Share this post

Link to post
Share on other sites

No probs, thank you and you're welcome :)

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.