找回密码
 加入
搜索
查看: 1378|回复: 5

[AU3基础] [已解决]关于将密码框恢复显示

[复制链接]
发表于 2020-4-15 15:25:29 | 显示全部楼层 |阅读模式
本帖最后由 anythinging 于 2020-4-17 11:00 编辑

请教各位老师,如何在程序运行中,将密码输入框改成明文或改成密文,怎么设置都不管用。感谢指点!
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


Example()

Func Example()
    GUICreate("调整控件的样式") ; 创建一个居中显示的对话框

        $1        =        GUICtrlCreateInput('123',120,60,80,20,$ES_PASSWORD)
        $2        =        GUICtrlCreateInput('456',120,120,80,20)
                        GUICtrlSetStyle(-1,$ES_PASSWORD )
        $bt1        =        GUICtrlCreateButton('1',50,350,50,30)

        GUISetState(@SW_SHOW)

    ; 循环到用户退出.
    While 1
        Switch GUIGetMsg()
            Case $bt1
                                GUICtrlSetStyle($2,$ES_PASSWORD )
                                GUICtrlSetStyle($1,-1,-1)
                        Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example

发表于 2020-4-15 18:43:09 | 显示全部楼层

#include <GuiEdit.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
        GUICreate("调整控件的样式") 
        $Input1 = GUICtrlCreateInput('123', 120, 60, 80, 20, $ES_PASSWORD)
        $Input2 = GUICtrlCreateInput('456', 120, 120, 80, 20)
        $bt1 = GUICtrlCreateButton('显示密码', 50, 350, 80, 30)
        GUISetState(@SW_SHOW)
        While 1
                Switch GUIGetMsg()
                        Case $bt1
                                _GUICtrlEdit_SetPasswordChar($Input1)
                                GUICtrlSetData($Input1,GUICtrlRead($Input1))
                        Case $GUI_EVENT_CLOSE
                                ExitLoop
                EndSwitch
        WEnd
EndFunc   ;==>Example



点评

高,实在是高!感谢指点!  发表于 2020-4-16 09:45

评分

参与人数 1金钱 +30 收起 理由
anythinging + 30 赞一个!

查看全部评分

发表于 2020-4-15 16:07:11 | 显示全部楼层
本帖最后由 chzj589 于 2020-4-15 20:24 编辑

查看:查看附录 GUI 控件样式表.
$ES_PASSWORD,   0x0020,   输入编辑控件的每个字符显示为星号 (*).
这只是 输入编辑控件的每个字符显示为星号,不是密文

#include <GuiEdit.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
        GUICreate("调整控件的样式")
        $Input2 = GUICtrlCreateInput('456', 120, 120, 80, 20, $ES_PASSWORD)
        $Input1 = GUICtrlCreateInput('123', 120, 60, 80, 20, $ES_PASSWORD)
        $bt1 = GUICtrlCreateButton('显示密码', 50, 350, 80, 30)
        $bt2 = GUICtrlCreateButton('返回星号', 180, 350, 80, 30)
        GUISetState(@SW_SHOW)
        While 1
                Switch GUIGetMsg()
                        Case $bt1
                                _GUICtrlEdit_SetPasswordChar($Input1)
                                GUICtrlSetData($Input1, GUICtrlRead($Input1))
                                _GUICtrlEdit_SetPasswordChar($Input2)
                                GUICtrlSetData($Input2, GUICtrlRead($Input2))
                                GUICtrlSetFont($Input1, 10, 400, 0, 'Arial')
                                GUICtrlSetFont($Input2, 10, 400, 0, 'Arial')
                        Case $bt2
                                _GUICtrlEdit_SetPasswordChar($Input1, "*") ; 更改密码字符为 $
                                GUICtrlSetData($Input1, GUICtrlRead($Input1))
                                GUICtrlSetFont($Input1, 14, 400);, 0, 'Arial')
                                _GUICtrlEdit_SetPasswordChar($Input2, "*") ; 更改密码字符为 $
                                GUICtrlSetData($Input2, GUICtrlRead($Input2))
                                GUICtrlSetFont($Input2, 14, 400);, 0, 'Arial')
                        Case $GUI_EVENT_CLOSE
                                ExitLoop
                EndSwitch
        WEnd
EndFunc   ;==>Example
 楼主| 发表于 2020-4-15 17:43:58 | 显示全部楼层
chzj589 发表于 2020-4-15 16:07
查看:查看附录 GUI 控件样式表.
$ES_PASSWORD,   0x0020,   输入编辑控件的每个字符显示为星号 (*).
...

对,对,就是在程序运行过程中,想把那个输入框变成输入星号或变成正常,都无法实现。
 楼主| 发表于 2020-4-16 09:45:04 | 显示全部楼层
zghwelcome 发表于 2020-4-15 18:43
[au3]
#include
#include

高,实在是高!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-2 02:42 , Processed in 0.096201 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表