Sign in to follow this  
Followers 0
Xenobiologist

Changing Style Of An Inputbox?

15 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

Speak of the devil :think:


[center]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.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
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.

 

Share this post


Link to post
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

Share this post


Link to post
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.

 

Share this post


Link to post
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

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

:)

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

[center]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.[/center]

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  
Followers 0