找回密码
 加入
搜索
查看: 5320|回复: 15

[AU3基础] 怎么写个登入器

 火.. [复制链接]
发表于 2012-7-2 16:56:58 | 显示全部楼层 |阅读模式
点击登入 登入到另一个窗口 假设用户123密码456怎么写

本帖子中包含更多资源

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

×
发表于 2012-7-2 17:12:02 | 显示全部楼层
这个界面是你写的的还说是说你要操作这个窗口?
 楼主| 发表于 2012-7-2 18:34:36 | 显示全部楼层
写啊  写代码进去 把TXT1赋予123  text2赋予456 不知道怎么写 然后判断
发表于 2012-7-2 18:38:39 | 显示全部楼层
本帖最后由 xuanfeng1234567 于 2012-7-2 18:44 编辑

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Munu", 228, 135, 192, 124)
$Label1 = GUICtrlCreateLabel("用户:", 24, 16, 40, 17)
$Label2 = GUICtrlCreateLabel("密码:", 24, 56, 40, 17)
$Input1 = GUICtrlCreateInput("", 72, 16, 121, 21)
$Input2 = GUICtrlCreateInput("", 72, 48, 121, 21,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Button1 = GUICtrlCreateButton("登入", 40, 88, 51, 25)
$name = GUICtrlCreateButton("退出", 144, 88, 51, 25)
GUISetState(@SW_SHOW)
$Form2 = GUICreate("窗体1", 405, 294, 302, 218)
GUISetState(@SW_HIDE)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE,$name
                        Exit
                Case $Button1
                        oenter()
        EndSwitch
WEnd
善用搜索!
Func oenter()
$read1 = GUICtrlRead($Input1)
$read2 = GUICtrlRead($Input2)
If $read1 = "123" And $read2 = "456" Then
        GUISetState(@SW_HIDE,$Form1)
        MsgBox(0,"","密码正确,进入下一个界面")
        GUISetState(@SW_SHOW,$Form2)
Else
        MsgBox(0,"","帐号或密码错误请重新输入")
        GUICtrlSetData($Input2,"")
EndIf
EndFunc
发表于 2012-7-2 18:45:19 | 显示全部楼层

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("登陆", 263, 174, 461, 235)
$Label1 = GUICtrlCreateLabel("用户", 30, 30, 30, 25)
$Label2 = GUICtrlCreateLabel("密码", 30, 70, 30, 30)
$Input1 = GUICtrlCreateInput("", 80, 30, 140, 25)
$Input2 = GUICtrlCreateInput("", 80, 70, 140, 25, $ES_PASSWORD)
$Button1 = GUICtrlCreateButton("登入", 50, 120, 60, 35)
$Button2 = GUICtrlCreateButton("退出", 150, 120, 60, 35)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("已登录", 623, 449, 192, 114)
$MonthCal1 = GUICtrlCreateMonthCal("2012/07/02", 40, 48, 267, 153)
GUISetState(@SW_HIDE)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $username = GUICtrlRead($Input1)
                        $password = GUICtrlRead($Input2)
                        If $username = "" And $password = "" Then
                                MsgBox(16, "错误!", "请输入用户名和密码!")
                        ElseIf $username = "" And $password <> "" Then
                                MsgBox(16, "错误!", "请输入用户名!")
                        ElseIf $username <> "" And $password = "" Then
                                MsgBox(16, "错误!", "请输入密码!")
                        Else
                                If $username <> "123" Or $password <> "456" Then
                                        MsgBox(16, "错误!", "用户名或密码错误,请重新输入!")
                                Else
                                        GUISetState(@SW_HIDE, $Form1)
                                        GUISetState(@SW_SHOW, $Form2)
                                        ExitLoop
                                EndIf
                        EndIf
                Case $Button2
                        Exit
        EndSwitch
WEnd

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd
发表于 2012-7-2 19:22:43 | 显示全部楼层
#region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_icon=C:\Windows\system32\SHELL32.dll|-3
#PRE_Outfile=H:\2225.exe
#PRE_Res_requestedExecutionLevel=None
#PRE_Run_Tidy=y
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $Uid
$mdb_pwd = ""
$mdb_path = "z.mdb"
$tblname = "zzm"
#region ### START Koda GUI section ###
$Form1 = GUICreate("登入框", 186, 131, -1, -1)
$Input1 = GUICtrlCreateInput("", 16, 16, 153, 21)
$Input2 = GUICtrlCreateInput("", 16, 52, 153, 21, $ES_PASSWORD)
$Button1 = GUICtrlCreateButton("注  册", 16, 88, 65, 25)
$Button2 = GUICtrlCreateButton("登  入", 104, 88, 65, 25)

$Form2 = GUICreate("注册框", 204, 215, -1, -1)
$Input01 = GUICtrlCreateInput("", 64, 16, 121, 21)
$Input02 = GUICtrlCreateInput("", 64, 54, 121, 21)
$Input03 = GUICtrlCreateInput("", 64, 93, 121, 21)
$Input04 = GUICtrlCreateInput("", 64, 131, 121, 21)
$Label1 = GUICtrlCreateLabel("用户名", 16, 20, 40, 17)
$Label2 = GUICtrlCreateLabel("密码", 16, 57, 28, 17)
$Label3 = GUICtrlCreateLabel("Q  Q", 16, 95, 26, 17)
$Label4 = GUICtrlCreateLabel("E-mail", 16, 132, 34, 17)
$Button01 = GUICtrlCreateButton("提  交", 16, 168, 75, 25)
$Button02 = GUICtrlCreateButton("取  消", 112, 168, 75, 25)

#endregion ### END Koda GUI section #
GUISwitch($Form1)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        GUISetState(@SW_SHOW, $Form2)
                Case $Button2
                        If GUICtrlRead($Input1) = "" Then
                                MsgBox(64, "提示", "请输入用户名!", 5)
                        ElseIf GUICtrlRead($Input2) = "" Then
                                MsgBox(64, "提示", "请输入密码!", 5)
                        Else
                                login()
                        EndIf
                Case $Button02
                        GUISetState(@SW_HIDE, $Form2)
                Case $Button01
                        reg()
        EndSwitch
WEnd
Func login()
        $user1 = GUICtrlRead($Input1)
        $pass1 = GUICtrlRead($Input2)
        $addfld = ObjCreate("ADODB.Connection")
        $addfld.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_path)
        $RS = ObjCreate("ADODB.Recordset")
        $RS.ActiveConnection = $addfld
        $RS.Open("SELECT zzm.name, zzm.pass FROM zzm WHERE zzm.name=" & "'" & $user1 & "'")
        If $RS.bof < 0 Then
                MsgBox(64, "提示", "未注册用户,请先注册!", 5)
        Else
                $user2 = StringReplace($RS.Fields(0).value, " ", "")
                $pass2 = StringReplace($RS.Fields(1).value, " ", "")
                While Not $RS.eof And Not $RS.bof
                        If @error = 1 Then ExitLoop
                        If $user1 = $user2 And $pass1 = $pass2 Then
                                $Uid = $user1
                                MsgBox(64, "登入口", "欢迎回来尊敬的 " & $Uid, 5)
                                GUISetState(@SW_HIDE, $Form1)
                                main()
                        Else
                                MsgBox(64, "错误", "密码错误!", 5)
                        EndIf
                        $RS.movenext
                WEnd
                $RS.close
                $addfld.Close
        EndIf
EndFunc   ;==>login
Func reg()
        $reg_user = GUICtrlRead($Input01)
        $reg_pass = GUICtrlRead($Input02)
        $reg_qq = GUICtrlRead($Input03)
        $reg_email = GUICtrlRead($Input04)
        $addfld = ObjCreate("ADODB.Connection")
        $addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_path & ";Jet Oledb:Database Password=" & $mdb_pwd)
        $addfld.Execute("insert into zzm (name,pass,qq,e_mail) values('" & $reg_user & "','" & $reg_pass & "','" & $reg_qq & "','" & $reg_email & "')")
        $addfld.close
        MsgBox(4096, "提示:", " 注册成功!")
        GUISetState(@SW_HIDE, $Form2)
        GUICtrlSetData($Input01, '')
        GUICtrlSetData($Input02, '')
        GUICtrlSetData($Input03, '')
        GUICtrlSetData($Input04, '')

EndFunc   ;==>reg
Func main()
        $Form3 = GUICreate("主窗体  " & "当前用户: " & $Uid, 633, 447, -1, -1)
        $Button001 = GUICtrlCreateButton("我只是个测试的!", 128, 120, 377, 161)
        GUICtrlSetFont(-1, 24, 400, 0, "黑体")
        GUISetState(@SW_SHOW)
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        Case $Button001
                                Exit
                EndSwitch
        WEnd
EndFunc   ;==>main


论坛有例子 搜出来
发表于 2012-7-2 21:02:34 | 显示全部楼层
论坛有例子 搜出来
发表于 2012-7-2 21:03:43 | 显示全部楼层
顶顶。。更电池民抗。
发表于 2012-7-2 21:03:48 | 显示全部楼层
搜出来不错的列子
发表于 2012-7-2 22:19:26 | 显示全部楼层
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("登陆", 263, 174, 461, 235)
$Label1 = GUICtrlCreateLabel("用户", 30, 30, 30, 25)
$Label2 = GUICtrlCreateLabel("密码", 30, 70, 30, 30)
$Input1 = GUICtrlCreateInput("", 80, 30, 140, 25)
$Input2 = GUICtrlCreateInput("", 80, 70, 140, 25, $ES_PASSWORD)
$Button1 = GUICtrlCreateButton("登入", 50, 120, 60, 35)
$Button2 = GUICtrlCreateButton("退出", 150, 120, 60, 35)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("已登录", 623, 449, 192, 114)
$MonthCal1 = GUICtrlCreateMonthCal("2012/07/02", 40, 48, 267, 153)
GUISetState(@SW_HIDE)
#EndRegion ### END Koda GUI section ###
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $oIE = _IECreate ("http://anply.0fees.net/d/Ax.txt",0,0)
                        $aReturn = _IEBodyReadText ($oIE)
                        $username = GUICtrlRead($Input1)
                        $password = GUICtrlRead($Input2)
                        If $username = "" And $password = "" Then
                                MsgBox(16, "错误!", "请输入用户名和密码!")
                        ElseIf $username = "" And $password <> "" Then
                                MsgBox(16, "错误!", "请输入用户名!")
                        ElseIf $username <> "" And $password = "" Then
                                MsgBox(16, "错误!", "请输入密码!")
                        Else
                                If $username <> BinaryToString($aReturn) Or $password <> "456" Then
                                        MsgBox(16, "错误!", "用户名或密码错误,请重新输入!")
                                Else
                                        GUISetState(@SW_HIDE, $Form1)
                                        GUISetState(@SW_SHOW, $Form2)
                                        ExitLoop
                                EndIf
                        EndIf
                Case $Button2
                        Exit
        EndSwitch
WEnd
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd
用户名:管理员
密码:456
呵呵。我来个DIY
发表于 2012-7-3 09:11:14 | 显示全部楼层
都缺少回车切换下一个控件哈。。
发表于 2012-7-3 11:06:12 | 显示全部楼层
都不错哈!!
发表于 2012-7-3 17:33:06 | 显示全部楼层
我每次看帖必回的~~藏了
发表于 2012-7-3 22:19:16 | 显示全部楼层
都缺少回车切换下一个控件哈。。
menfan1 发表于 2012-7-3 09:11



    如这位高手说的,怎么检测控件按下了回车就产生一个事件,我新手
发表于 2012-7-4 15:04:14 | 显示全部楼层
我每次看帖必回的~~藏了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-20 06:03 , Processed in 0.083887 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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