请教下,关于登陆注册的问题
有没有注册然后输入帐号密码登录功能的例子,我在论坛找了半天都没找到,请高手们指教下 ..登陆什么? 注册什么? 我上图,下面是代码#include <ButtonConstants.au3>#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 448, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 72, 40, 225, 41, $ES_WANTRETURN)
;~ GUICtrlSetData(-1, "Edit1")
$Edit2 = GUICtrlCreateInput("", 72, 104, 225, 41, $WS_EX_TRANSPARENT)
;~ GUICtrlSetData(-1, "Edit2")
$Button1 = GUICtrlCreateButton("登陆", 320, 40, 97, 33)
$Button2 = GUICtrlCreateButton("注册", 320, 104, 97, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
$zhanghao = GUICtrlRead($Edit1)
$mima = GUICtrlRead($Edit2)
IniWrite(@ScriptDir & "\user.ini" , "账号" , $zhanghao ,$zhanghao)
IniWrite(@ScriptDir & "\pod.ini" , "密码" , $mima ,$mima)
Case $Button1
$zhanghao = GUICtrlRead($Edit1)
$mima = GUICtrlRead($Edit2)
$user = IniRead(@ScriptDir & "\user.ini" , "账号" , $zhanghao,"")
$pod =IniRead (@ScriptDir & "\pod.ini" , "密码" ,$mima,"")
MsgBox(0,"",$zhanghao)
MsgBox(0,"",$user)
If $zhanghao = $user And $mima = $pod Then
MsgBox(0,"","登陆成功")
EndIf
;~ Select
;~ Case $zhanghao = $user And $mima = $pod
;~ MsgBox(0,"","登陆成功")
;~ Case $zhanghao = 0
;~ MsgBox(0,"","没填账号")
;~ Case $mima = 0
;~ MsgBox(0,"","没填密码")
;~ EndSelect
;~ MsgBox(0,$zhanghao,$mima)
;~ FileWriteLine(@ScriptDir & "\system.txt" , "密码: " & $mima)
EndSwitch
WEnd
现在是判断账号密码的时候有问题 说具体点,你想怎么操作。 想QQ那样,注册账号我是用INI文件来记录账号密码,然后登陆,现在就是卡在判断账号密码的时候不会给条件 本帖最后由 水木子 于 2010-8-23 19:45 编辑
这是我刚学习AU3时做的练习题,见笑啦!#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 afan前辈 真是神速,我刚放上去你就来了。 本帖最后由 xjdjpbp 于 2010-8-23 18:55 编辑
回覆 7# 水木子
受益良多~
之前就想要作一個登錄器
無奈能力有限
現在終於可以好好的學習、消化了
謝謝水木子版大
======================================
關於這一段
Switch $nMsg
Case $Button2, -3
Exit
在$Button2後面的-3是什麼意思?
Switch <表達式>
Case <值> [,<值> ...]
語句1
...
[,<值> ...]
語句2
...]
[Case Else
語句N
...]
EndSwitch
找了一下doc,還是不懂= =
有哪位仁兄可以跟我指導一下嗎? 本帖最后由 水木子 于 2010-8-23 18:51 编辑
回复 9# xjdjpbp
这是N久以前写的,逻辑结构方面都很乱,不值得学习,了解下思路就可以了。
我抽空整理一下,免得误导新人,因为我觉得编程养成良好的书写习惯是很重要的。 回复 9# xjdjpbp
关于你的那个问题,看看这里你就明白了。
http://www.autoitx.com/forum.php?mod=viewthread&tid=17819&rpid=198120&ordertype=0&page=1#pid198120 本帖最后由 xjdjpbp 于 2010-8-23 19:00 编辑
回覆 10# 水木子
呵呵,版大辛苦了
有看我在9樓發的問題的話,幫忙解釋一下喔{:face (117):}
寫程式時所做的註解,畢竟大部分都是寫給自己看得
哈哈~所以不怪你的
====================================
(已解決)
沒辦法,你速度太快了
回不上你的速度
{:face (87):} 回复 12# xjdjpbp
我不是给了链接吗!去看看吧!{:1_550:} 回复 9# xjdjpbp
当GetMsg()的消息为$Button2或$Exit(-3)时,执行Exit.
我现在懒得写代码的话,就直接Do
sleep(10)
until GetMsg() = -3呵呵... 回复 14# republican
原來是這樣@@
又讓我多學了一招
真是有夠懶得寫法....
不過還挺妙的WOW
3Q
页:
[1]
2