找回密码
 加入
搜索
查看: 4762|回复: 11

[AU3基础] (已解决)更改文本框输入的密码的显示状态,谢谢afan跟lynfr8

  [复制链接]
发表于 2011-11-19 15:32:57 | 显示全部楼层 |阅读模式
本帖最后由 xyhqqaa 于 2011-11-20 04:52 编辑

新手,想更改文本框的显示状态,当星号打钩的时候,输入为星号字符。星号去掉的时候,则显示为明文状态。。。。搜索论坛好像没看到。。囧
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 496, 108, 272, 233)
$Checkbox1 = GUICtrlCreateCheckbox("星号", 312, 32, 97, 57)
GUICtrlSetState($Checkbox1,$gui_checked)
$Input1 = GUICtrlCreateInput("Input1", 64, 48, 225, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-11-19 16:11:38 | 显示全部楼层
_GUICtrlEdit_SetPasswordChar()

评分

参与人数 1金钱 +10 收起 理由
xyhqqaa + 10

查看全部评分

 楼主| 发表于 2011-11-19 16:43:21 | 显示全部楼层
回复 2# afan   谢谢A版哥。。您给的这个参数。俺慢慢消化下。。刚搜索看到顽固不化大哥的一个相类似的例子。。改了下可用。。但还是需要慢慢消化...谢谢您。。。。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 496, 108, 272, 233)
$Checkbox1 = GUICtrlCreateCheckbox("星号", 312, 32, 97, 57)
GUICtrlSetState($Checkbox1, $gui_checked)
$Input1 = GUICtrlCreateInput("Input1", 64, 48, 225, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
$yes = False
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Checkbox1
                        $a = GUICtrlRead($Input1)
                        GUICtrlDelete($Input1)
                        If $yes = False Then
                                $Input1 = GUICtrlCreateInput("",  64, 48, 225, 21, $ES_AUTOHSCROLL)
                                $yes = True
                        Else
                                $Input1 = GUICtrlCreateInput("",  64, 48, 225, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
                                $yes = False
                        EndIf        
                        GUICtrlSetData($Input1, $a)
        EndSwitch

WEnd
 楼主| 发表于 2011-11-19 17:27:50 | 显示全部楼层
_GUICtrlEdit_SetPasswordChar()  看不懂- -  阿门。。。。
发表于 2011-11-19 18:28:06 | 显示全部楼层
回复 4# xyhqqaa
#include <GuiEdit.au3>

$Form1 = GUICreate('Form1', 496, 108)
$Checkbox1 = GUICtrlCreateCheckbox('星号', 312, 32, 97, 57)
GUICtrlSetState(-1, 1)
$Input1 = GUICtrlCreateInput('Input1', 64, 48, 225, 21, $ES_PASSWORD)

GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Checkbox1
                        If GUICtrlRead($nMsg) = 4 Then
                                _GUICtrlEdit_SetPasswordChar($Input1)
                        Else
                                _GUICtrlEdit_SetPasswordChar($Input1, '*')
                        EndIf
                        GUICtrlSetState($Input1, 256)
                        _GUICtrlEdit_SetSel($Input1, -1, -1)

        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
xyhqqaa + 10 谢谢A版。。。这样一看就明白了0 0.。谢谢。 ...

查看全部评分

发表于 2011-11-19 19:41:02 | 显示全部楼层
_GUICtrlEdit_SetPasswordChar()  看不懂- -  阿门。。。。
xyhqqaa 发表于 2011-11-19 17:27



看帮助
发表于 2011-11-19 19:53:59 | 显示全部楼层
回复 4# xyhqqaa
#include <GuiEdit.au3>
$Form1 = GUICreate('Form1', 496, 108)
$Checkbox1 = GUICtrlCreateCheckbox('星号', 312, 32, 97, 57)
GUICtrlSetState(-1, 1)
$Input1 = GUICtrlCreateInput('Input1', 64, 48, 225, 21, $ES_PASSWORD)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Checkbox1
                        $show = GUICtrlRead($Input1)
                        GUICtrlDelete($Input1)
                        If GUICtrlRead($nMsg) = 4 Then
                                $Input1 = GUICtrlCreateInput($show, 64, 48, 225, 21)
                        Else
                                $Input1 = GUICtrlCreateInput($show, 64, 48, 225, 21, $ES_PASSWORD)
                        EndIf
        EndSwitch
WEnd
这个简单能看懂了吧?

评分

参与人数 1金钱 +10 收起 理由
xyhqqaa + 10 囧。。再看不懂估计会被吃了。。。

查看全部评分

 楼主| 发表于 2011-11-19 20:05:45 | 显示全部楼层
回复 7# lynfr8


    谢谢lynfr8大哥。。。谢谢。。。。伸手党鸭梨大。。。囧。。。
 楼主| 发表于 2011-11-19 20:07:14 | 显示全部楼层
回复 6# lpxx


    谢谢关注。。看了帮助看不明白用法。。。。A版那例子让俺活了  囧。。知道伸手不好。。。
发表于 2011-11-19 20:10:40 | 显示全部楼层
回复 9# xyhqqaa

_GUICtrlEdit_SetPasswordChar
--------------------------------------------------------------------------------
设置或清除编辑控件的密码字符
#Include <GuiEdit.au3>
_GUICtrlEdit_SetPasswordChar($hWnd[, $cDisplayChar = "0"])

参数
$hWnd 控件句柄
$cDisplayChar [可选参数] 用户输入字符的显示字符
如果此参数 0,则删除当前密码字符,显示用户直接输入的字符
AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)

$Debug_Ed = False ; 检查传递给 Edit 函数的类名, 设置为True,并使用另一个控件句柄,看看它的工作.

_Main()

Func _Main()
    Local $hEdit

    ; 创建 GUI
    GUICreate("(Internal) Edit 设置或清除编辑控件的密码字符", 400, 300)
    $hEdit = GUICtrlCreateInput("控件内部测试", 2, 2, 394, 25, $ES_PASSWORD)
    GUISetState()

    MsgBox(4096, "提示", "密码字符: " & _GUICtrlEdit_GetPasswordChar($hEdit))

    _GUICtrlEdit_SetPasswordChar($hEdit, "$") ; 更改密码字符为 $
    
    MsgBox(4096, "提示", "密码字符: " & _GUICtrlEdit_GetPasswordChar($hEdit))

    _GUICtrlEdit_SetPasswordChar($hEdit) ; 用户输入的显示字符.

    MsgBox(4096, "提示", "密码字符: " & _GUICtrlEdit_GetPasswordChar($hEdit))

    ; 循环到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main
帮助文件已经表达得够清楚了

评分

参与人数 1金钱 +10 收起 理由
xyhqqaa + 10

查看全部评分

 楼主| 发表于 2011-11-20 01:00:11 | 显示全部楼层
回复 10# lynfr8


    恩恩 - -  .//之前看了例子,脑子没反应过来///   新手努力中....谢谢
发表于 2012-2-7 03:57:51 | 显示全部楼层
又知道了_GUICtrlEdit_SetPasswordChar()
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-30 23:23 , Processed in 0.087187 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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