本帖最后由 Qokelate 于 2012-4-4 01:13 编辑
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
PwdBox()
MsgBox(0, '你实际输入的是', $UserInput)
Exit
Func PwdBox()
Global $UserInput, $InputLen
GUICreate("Form1", 194, 111, 192, 114)
Global $CtrlID = GUICtrlCreateEdit('', 32, 40, 131, 20)
Global $hControl = GUICtrlGetHandle($CtrlID)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
EndFunc ;==>PwdBox
Func WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $iCode = BitShift($wParam, 16)
Local $ShowStr, $BoxString, $BoxStrLen
Switch $lParam
Case $hControl
Switch $iCode
Case $EN_CHANGE
$BoxString = GUICtrlRead($CtrlID)
$BoxStrLen = StringLen($BoxString)
If $BoxStrLen < $InputLen Then
$InputLen -= 1
$UserInput = StringTrimRight($UserInput, 1)
Else
$UserInput &= StringRight($BoxString, 1)
$InputLen += 1
EndIf
For $a = 1 To $InputLen
$ShowStr &= ChrW(Random(1,65535,1))
Next
GUICtrlSetData($CtrlID, $ShowStr)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
|