#NoTrayIcon
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Path = @ScriptDir & "\Data.ini"
$Form1 = GUICreate("登陆界面", 320, 220)
GUICtrlCreateLabel("账号:", 40, 50, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateLabel("密码:", 40, 100, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Regist = GUICtrlCreateLabel("注册", 260, 50, 36, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0x008080)
$Input1 = GUICtrlCreateInput("", 90, 50, 160, 21)
$Input2 = GUICtrlCreateInput("", 90, 100, 160, 21, BitOR($ES_LOWERCASE, $ES_PASSWORD))
$Button1 = GUICtrlCreateButton("登陆", 90, 168, 60, 30, $WS_GROUP)
$Button2 = GUICtrlCreateButton("退出", 190, 168, 60, 30, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button2, -3
Exit
Case $Button1
Login(GUICtrlRead($Input1), GUICtrlRead($Input2))
Case $Regist
zhuce()
EndSwitch
WEnd
Func Login($sName, $sPass)
If $sName <> '' And $sPass <> '' Then
If IniRead($Path, "Data", $sName, '') = $sPass Then
MsgBox(64, '提示', '登陆成功,谢谢使用。')
Exit
Else
MsgBox(48, '错误', '密码错误,请确认。')
EndIf
Else
MsgBox(48, '错误', '请正确输入登陆信息')
EndIf
EndFunc ;==>Login
Func zhuce()
GUISetState(@SW_DISABLE, $Form1)
$Form11 = GUICreate("注册账号", 300, 260)
GUICtrlCreateLabel("账号:", 50, 30, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateLabel("密码:", 50, 100, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateLabel("确认密码:", 20, 150, 84, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Input11 = GUICtrlCreateInput("", 100, 30, 150, 21)
$Input12 = GUICtrlCreateInput("", 100, 100, 150, 21, BitOR($ES_LOWERCASE, $ES_PASSWORD))
$Input13 = GUICtrlCreateInput("", 100, 150, 150, 21, BitOR($ES_LOWERCASE, $ES_PASSWORD))
$Button11 = GUICtrlCreateButton("注册", 100, 200, 60, 30, $WS_GROUP)
$Button12 = GUICtrlCreateButton("取消", 190, 200, 60, 30, $WS_GROUP)
$Button13 = GUICtrlCreateButton("确认账号是否可用", 100, 55, 150, 25, $WS_GROUP)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3, $Button12
GUISetState(@SW_ENABLE, $Form1)
GUIDelete($Form11)
ExitLoop
Case $Button11
$sName = GUICtrlRead($Input11)
$Pass1 = GUICtrlRead($Input12)
$Pass2 = GUICtrlRead($Input13)
If $sName <> "" And $Pass1 <> "" And $Pass2 <> "" Then
If $Pass1 = $Pass2 Then
IniWrite($Path, "Data", $sName, $Pass1)
MsgBox(64, '提示', '注册成功')
GUISetState(@SW_ENABLE, $Form1)
GUIDelete($Form11)
ExitLoop
Else
MsgBox(48, '错误', '请确认两次密码输入相同')
EndIf
Else
MsgBox(48, '错误', '请正确输入注册信息')
EndIf
Case $Button13
$sName = GUICtrlRead($Input11)
If $sName <> '' Then
If IniRead($Path, 'Data', $sName, '') = '' Then
GUICtrlSetData($Button13, '此账号可用')
Else
GUICtrlSetData($Button13, '此账号已存在')
EndIf
Else
GUICtrlSetData($Button13, '账号不能留空')
EndIf
EndSwitch
WEnd
EndFunc ;==>zhuce