Jump to content

Changing Style Of An Inputbox?


Recommended Posts

Hi,

how can I change it?

Example code:

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$Input1 = GUICtrlCreateInput("AInput1", 48, 32, 121, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("AInput2", 48, 64, 121, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("AButton1", 240, 32, 75, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $Button1
        GUICtrlSetStyle($Input1, $ES_PASSWORD ,$WS_EX_CLIENTEDGE)
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Thanks! Can be easy, but I don't get it right now. :">

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

This is as close as I can come :(, maybe Gary could shed more lite, If I'm not mistaken I got the idea from him in a post many moons ago.

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$Input1 = GUICtrlCreateInput("AInput1", 48, 32, 121, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("AInput2", 48, 64, 121, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("Convert", 240, 32, 75, 25)
$Button2 = GUICtrlCreateButton('Reset, 240, 62, 75, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $Button1
        _SetPasswordStyle($Form1, $Input1, '=')
    Case $msg = $Button2
        _SetPasswordStyle($Form1, $Input1, '', 'Ms Sans Serif')
    Case Else
  ;;;;;;;
    EndSelect
WEnd


Func _SetPasswordStyle($hwnd_GUI, $hwnd_ControlID, $sEncode = '', $v_Font = 'Webdings', $i_FontSize = 9)
    Local $EM_SETPASSWORDCHAR = 0xCC
    If $sEncode = '' Then
        GUICtrlSendMsg($hwnd_ControlID, $EM_SETPASSWORDCHAR, 0, 0)
        ControlFocus($hwnd_GUI, '', $hwnd_ControlID)
        GUICtrlSetFont($hwnd_ControlID, $i_FontSize, '', '', $v_Font)
    Else
        GUICtrlSendMsg($hwnd_ControlID, $EM_SETPASSWORDCHAR, Asc($sEncode), 0)
        ControlFocus($hwnd_GUI, '', $hwnd_ControlID)
        GUICtrlSetFont($hwnd_ControlID, 6, '', '', $v_Font)
    EndIf
EndFunc

Edit:

I had a word that I had no idea what it meant as a button label :think:

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

#include <GUIConstants.au3>

; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$Input1 = GUICtrlCreateInput("AInput1", 48, 32, 121, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("AInput2", 48, 64, 121, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("AButton1", 240, 32, 75, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
      case $msg = $Button1
          _GuiCtrlEditChangePasswordChar($Input1)
    Case Else
   ;;;;;;;
    EndSelect
WEnd
Exit

Func _GuiCtrlEditChangePasswordChar(ByRef $h_edit, $s_newchar = '*')
    Local const $EM_SETPASSWORDCHAR = 0xCC
    GUISetState(@SW_LOCK)
    GUICtrlSetStyle($h_edit, $ES_PASSWORD ,$WS_EX_CLIENTEDGE)
    GUICtrlSendMsg($h_edit, $EM_SETPASSWORDCHAR, Asc($s_newchar), 0)
    GUISetState(@SW_UNLOCK)
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hi,

thank you very much! Works great. Is there any way to get the ANSI chr(149) back into the func?

I only found asc and chr as funcs and they won't work, I suppose.

I'll search a bit, but maybe someone is quicker. :think:

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

Hi,

thank you very much! Works great. Is there any way to get the ANSI chr(149) back into the func?

I only found asc and chr as funcs and the won't work, I suppose.

I'll search a bit, but maybe someone is quicker. :think:

So long,

Mega

Which one are you talking about?

Edit:

And what do you mean "back in the function"?

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Func _GuiCtrlEditChangePasswordChar(ByRef $h_edit, $s_newchar = '*')
    Local const $EM_SETPASSWORDCHAR = 0xCC
    GUISetState(@SW_LOCK)
    If StringInStr(@OSVersion,"WIN_XP") And @NumParams = 1 Then
        Local $s_text = GUICtrlRead($h_edit)
        Local $pos = ControlGetPos(WinGetTitle(""),"",$h_edit)
        GUICtrlDelete($h_edit)
        $h_edit = GUICtrlCreateInput($s_text, $pos[0], $pos[1], $pos[2], $pos[3], $ES_PASSWORD, $WS_EX_CLIENTEDGE)
    Else
        GUICtrlSetStyle($h_edit, $ES_PASSWORD ,$WS_EX_CLIENTEDGE)
        GUICtrlSendMsg($h_edit, $EM_SETPASSWORDCHAR, Asc($s_newchar), 0)
    EndIf
        
    GUISetState(@SW_UNLOCK)
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Which one are you talking about?

Edit:

And what do you mean "back in the function"?

Hi,

yeah you both are really cool and always heplful guys!!! Thanks!

I meant when creating an InputBox with $ES_PASSWORD, then the things you type are masked with another sign. I thought it is 149.

Your both funcs change the password mask sign in something else.

It is not basic, but maybe it is possible to get the original sign back.

Clear? It is 3 o'clock in the morning, so my English could be better, I know. :">

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

My above post should do what you want, the char your looking for is the default password char when the ES_PASSWORD style is used to create the control, and the comctrl is version 6

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

My above post should do what you want, the char your looking for is the default password char when the ES_PASSWORD style is used to create the control, and the comctrl is version 6

Hi,

works fine. Does the char password char differ on Windows versions (2000, 98)?

I think so, because you check for WIN_XP.

Nevertheless, thank you!

After having a closer look, I even understood what your func does. :think:

Simple, but ingenious.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

works fine. Does the char password char differ on Windows versions (2000, 98)?

I think so, because you check for WIN_XP.

Nevertheless, thank you!

After having a closer look, I even understood what your func does. :think:

Simple, but ingenious.

So long,

Mega

Win XP the default password char is black circles (ComCtl32.dll version 6)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • 11 months later...

Hi,

is there in the meantime an easier way, to set the char or to disable the Password style?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 1 year later...

Sorry for the bumping, I just have a question...

How can I disable the '_GuiCtrlEditChangePasswordChar'?

I tried

#include <GUIConstants.au3>

; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$Input1 = GUICtrlCreateInput("AInput1", 48, 32, 121, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("AInput2", 48, 64, 121, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("AButton1", 240, 32, 75, 25)
$Button2 = GUICtrlCreateButton("AButton2", 240, 64, 75, 25); <<<<<<<<<<<<< new button
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
      case $msg = $Button1
          $ChangePass = _GuiCtrlEditChangePasswordChar($Input1)
      Case $msg = $Button2
        $ChangePass =0; <<<<<<<<<<<<<<< didn't work... =(
    Case Else
 ;;;;;;;
    EndSelect
WEnd
Exit

Func _GuiCtrlEditChangePasswordChar(ByRef $h_edit, $s_newchar = '*')
    Local const $EM_SETPASSWORDCHAR = 0xCC
    GUISetState(@SW_LOCK)
    If StringInStr(@OSVersion,"WIN_XP") And @NumParams = 1 Then
        Local $s_text = GUICtrlRead($h_edit)
        Local $pos = ControlGetPos(WinGetTitle(""),"",$h_edit)
        GUICtrlDelete($h_edit)
        $h_edit = GUICtrlCreateInput($s_text, $pos[0], $pos[1], $pos[2], $pos[3], $ES_PASSWORD, $WS_EX_CLIENTEDGE)
    Else
        GUICtrlSetStyle($h_edit, $ES_PASSWORD ,$WS_EX_CLIENTEDGE)
        GUICtrlSendMsg($h_edit, $EM_SETPASSWORDCHAR, Asc($s_newchar), 0)
    EndIf
        
    GUISetState(@SW_UNLOCK)
EndFunc

And it didn't work...

Thanks :)

Edited by Info
Link to comment
Share on other sites

  • Moderators

:)

Case $msg = $Button2
        $ChangePass = _GuiCtrlEditChangePasswordChar($Input1, "")
:)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 9 years later...
#include <GUIConstants.au3>
#include <FontConstants.au3>
$Form1 = GUICreate("AForm1", 300, 100, 192, 125)
$Input1 = GUICtrlCreateInput("AInput1", 48, 32, 121, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
;$Input2 = GUICtrlCreateInput("AInput2", 48, 64, 121, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("N", 170, 31, 25, 23) ;;Webdings
;GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTUNDER, "Webdings")
GUICtrlSetFont(-1, 12, -1, -1, "Webdings", 5)
$Button2 = GUICtrlCreateButton("N", 170, 31, 25, 23)
GUICtrlSetFont(-1, 12, -1, $GUI_FONTSTRIKE , "Webdings")
GUICtrlSetState($Button2, $gui_hide)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $Button1
        _SetPasswordStyle($Form1, $Input1, '=')
        GUICtrlSetState($Button1, $gui_hide)
        GUICtrlSetState($Button2, $gui_show)
    Case $msg = $Button2
        _SetPasswordStyle($Form1, $Input1, '', 'Ms Sans Serif')
        GUICtrlSetState($Button2, $gui_hide)
        GUICtrlSetState($Button1, $gui_show)
    Case Else
  ;;;;;;;
    EndSelect
WEnd


Func _SetPasswordStyle($hwnd_GUI, $hwnd_ControlID, $sEncode = '', $v_Font = 'Webdings', $i_FontSize = 9)
    Local $EM_SETPASSWORDCHAR = 0xCC
    If $sEncode = '' Then
        GUICtrlSendMsg($hwnd_ControlID, $EM_SETPASSWORDCHAR, 0, 0)
        ControlFocus($hwnd_GUI, '', $hwnd_ControlID)
        GUICtrlSetFont($hwnd_ControlID, $i_FontSize, '', '', $v_Font)
    Else
        GUICtrlSendMsg($hwnd_ControlID, $EM_SETPASSWORDCHAR, Asc($sEncode), 0)
        ControlFocus($hwnd_GUI, '', $hwnd_ControlID)
        GUICtrlSetFont($hwnd_ControlID, 6, '', '', $v_Font)
    EndIf
EndFunc

try this....

Edited by Melba23
Giant quote removed
Link to comment
Share on other sites

  • Moderators

babai93,

Welcome to the AutoIt forums.

But did you realise that the post you quote dates from over 11 years ago? In future please do not resurrect threads from this far back - the language has changed so much that it is likely that the functionality has already been incorporated and the previously posted code will almost certainly not run in the current version of AutoIt without modification.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...