#include <GUIConstantsEx.au3>
$hGUI = GUICreate("_GUICtrlEdit_TogglePassChars - Demo", 300, 80)
$nInput = GUICtrlCreateInput("My Pass", 20, 20, 190, 20)
$nButton = GUICtrlCreateButton("Toggle Pass", 220, 20, 70, 20)
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $nButton
_GUICtrlEdit_TogglePassChars($hGUI, $nInput, -1, "*")
EndSwitch
WEnd
Func _GUICtrlEdit_TogglePassChars($hWnd, $hCtrl, $iToggleState=-1, $sPassChar="*")
If Not IsHWnd($hWnd) Then
$hWnd = WinGetHandle($hWnd)
EndIf
If Not IsHWnd($hCtrl) Then
$hCtrl = ControlGetHandle($hWnd, "", $hCtrl)
EndIf
Local Const $EM_SETPASSWORDCHAR = 0xCC
Local Const $EM_GETPASSWORDCHAR = 0xD2
Local $iPass_Char = 0
Local $aRet = DllCall("user32.dll", "long", "SendMessage", "hwnd", $hCtrl, "int", $EM_GETPASSWORDCHAR, "int", 0, "int", 0)
If IsArray($aRet) And Not $aRet[0] Then
$iPass_Char = Asc($sPassChar)
EndIf
If $iToggleState = 0 Then
$iPass_Char = 0
EndIf
DllCall("user32.dll", "none", "SendMessage", "hwnd", $hCtrl, "int", $EM_SETPASSWORDCHAR, "int", $iPass_Char, "int", 0)
DllCall("user32.dll", "none", "InvalidateRect", "hwnd", $hCtrl, "ptr", 0, "int", 1)
EndFunc