Force ES_PASSWORD style on Edit control

Get help with using AutoHotkey and its commands and hotkeys
Sam_
Posts: 106
Joined: 20 Mar 2014, 20:24

Force ES_PASSWORD style on Edit control

11 Jul 2017, 22:22

I'm having trouble forcing an edit control to use the ES_PASSWORD (0x20) style. As a simple test I open a blank notepad window, type a few lines of gibberish, and run

Code: Select all

ControlGet, ControlHwnd, Hwnd, , Edit1, Untitled - Notepad
Control, Style, +0x20, , ahk_id %ControlHwnd%
But the control's contents are not obfuscated as I would expect. Forcing the window/control to be redrawn

Code: Select all

WinSet, Redraw, , Untitled - Notepad
WinMove, Untitled - Notepad, , 10, 10
WinHide, Untitled - Notepad
WinShow, Untitled - Notepad
doesn't seem to help either. Other styles (like ES_CENTER 0x1) work as expected. I feel like this should be super simple. What am I missing?
User avatar
Masonjar13
Posts: 1473
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Force ES_PASSWORD style on Edit control

11 Jul 2017, 22:54

MSDN Edit Control Styles wrote:This style is valid only for single-line edit controls.
Edit Control Styles
OS: Windows 7 Ultimate | Editor: Notepad++
My Personal Function Library | Check Out My Computer Rig
Sam_
Posts: 106
Joined: 20 Mar 2014, 20:24

Re: Force ES_PASSWORD style on Edit control

12 Jul 2017, 12:33

Masonjar13 wrote:
MSDN Edit Control Styles wrote:This style is valid only for single-line edit controls.
Edit Control Styles
That possibility had occurred to me, but running

Code: Select all

Control, Style, -0x4, , ahk_id %ControlHwnd%	; Turn off ES_MULTILINE style
first doesn't help either. I've even tried playing around with Window Detective, but still can't get a 3rd-party Edit control to take on and apply the ES_PASSWORD style.
Sam_
Posts: 106
Joined: 20 Mar 2014, 20:24

Re: Force ES_PASSWORD style on Edit control

12 Jul 2017, 12:54

If notepad is complicating the issue, here is an example with AHK.
Using GuiControl works as expected:

Code: Select all

M := 10
Gui, Margin, %M%, %M%
Gui, Font, s16
Gui, Add, Edit, Password vEdit1 w200, Hello world
Gui, Add, Checkbox, -Checked vCheckbox1 gShow wp, Show password
Gui, Show
ControlGet, ControlHwnd, Hwnd, , Edit1, ahk_class AutoHotkeyGUI
;MsgBox % ControlHwnd
Return

Show()
{
	Global
	Gui, Submit, NoHide
	If Checkbox1
		{
		GuiControl, -Password, Edit1
		;Control, Style, -0x20, , ahk_id %ControlHwnd%
		}
	Else
		{
		GuiControl, +Password, Edit1
		;Control, Style, +0x20, , ahk_id %ControlHwnd%
		}
}
but Control does not:

Code: Select all

M := 10
Gui, Margin, %M%, %M%
Gui, Font, s16
Gui, Add, Edit, Password vEdit1 w200, Hello world
Gui, Add, Checkbox, -Checked vCheckbox1 gShow wp, Show password
Gui, Show
ControlGet, ControlHwnd, Hwnd, , Edit1, ahk_class AutoHotkeyGUI
;MsgBox % ControlHwnd
Return

Show()
{
	Global
	Gui, Submit, NoHide
	If Checkbox1
		{
		;GuiControl, -Password, Edit1
		Control, Style, -0x20, , ahk_id %ControlHwnd%
		}
	Else
		{
		;GuiControl, +Password, Edit1
		Control, Style, +0x20, , ahk_id %ControlHwnd%
		}
}
What am I missing here?

Return to “Ask For Help”

Who is online

Users browsing this forum: Billykid, Bing [Bot], Bral, mtschwrz, val and 149 guests