找回密码
 加入
搜索
查看: 4419|回复: 5

[AU3基础] 密码登录窗口问题 已解决

[复制链接]
发表于 2011-11-24 16:04:40 | 显示全部楼层 |阅读模式
本帖最后由 amxi 于 2011-11-27 13:37 编辑

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#Region ### START Koda GUI section ### Form=

Global $login=False
$name="admin"
$pwd="123456"
GUISetFont(12,400,1,"微软雅黑")
$sForm=GUICreate(" 登录窗口 ",230,150)
$label=GUICtrlCreateLabel("   用户登录",60,25,80,20)
$nlabel=GUICtrlCreateLabel("用户名",30,50,60,20)
$ninput=GUICtrlCreateinput("admin",90,50,110,20)
$plable1=GUICtrlCreateLabel("密 码",30,90,30,20)
$pinput=GUICtrlCreateinput("123456",90,80,110,20)
$Btn1=GUICtrlCreateButton(" 确定 ",100,120,50,25)
$Btn2=GUICtrlCreateButton(" 取消 ",165,120,50,25)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While $login=False
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Btn1
                         _login()
                         GUIDelete($sform)
                Case $Btn2
                        Exit
        EndSwitch
WEnd

;GUIDelete($sform)

MsgBox(0,"","hahahaha")

Global $a,$b,$c,$d,$e
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate(" 主窗口 ", 801, 601, 0, 0)
GUISetState(@SW_SHOW)

while 1 
        $msg=GUIGetMsg()
        Switch $msg
        case $gui_event_close
                Exit
        EndSwitch
WEnd

Func _login() ;登录检测
                
        if $name=GUICtrlRead($ninput) and $pwd=GUICtrlRead($pinput) Then
                MsgBox(0,"成功","欢迎使用")
                GUISetState(@sw_hide,$sform)
        EndIf
EndFunc


密码框登录成成功后主窗体不显示,是哪里的问题?请教
发表于 2011-11-24 16:39:32 | 显示全部楼层
脚本是不是你写的啊?

GUIDelete($sform)
GUISetState(@sw_hide,$sform)
发表于 2011-11-24 18:13:33 | 显示全部楼层
二楼正解...
发表于 2011-12-26 20:23:27 | 显示全部楼层
真是不小心啊。
发表于 2014-2-24 22:40:42 | 显示全部楼层
正在寻找这方面资料时候发现了这个帖子,得到了启示,测试了1楼代码无法进入到主窗口,发现是_login()函数中缺少一句代码:$login=true,修改后即正确了
得到启发,自己写了另外一种写法,异曲同工,希望以后找到此贴用到的朋友能得到启示!
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#Region ### START Koda GUI section ### Form=
 

$name="admin"
$pwd="123456"
GUISetFont(12,400,1,"微软雅黑")
$sForm=GUICreate(" 登录窗口 ",230,150)
$label=GUICtrlCreateLabel("   用户登录",60,25,80,20)
$nlabel=GUICtrlCreateLabel("用户名",30,50,60,20)
$ninput=GUICtrlCreateinput("admin",90,50,110,20)
$plable1=GUICtrlCreateLabel("密 码",30,90,30,20)
$pinput=GUICtrlCreateinput("123456",90,80,110,20)
$Btn1=GUICtrlCreateButton(" 确定 ",100,120,50,25)
$Btn2=GUICtrlCreateButton(" 取消 ",165,120,50,25)
 
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Btn1
                         Local $r=_login()
                                                 If $r=1 Then
                         GUIDelete($sform)
                                                 ExitLoop
                                                 EndIf
                Case $Btn2
                        Exit
        EndSwitch
WEnd
 
;GUIDelete($sform)
 
MsgBox(0,"","hahahaha")
 
;Global $a,$b,$c,$d,$e
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("FORM1", 801, 601)

GUISetState(@SW_SHOW)
 
while 1 
        $msg=GUIGetMsg()
        Switch $msg
                        case $gui_event_close
                Exit
        EndSwitch
WEnd
 
Func _login() ;登录检测
                
        if $name=GUICtrlRead($ninput) and $pwd=GUICtrlRead($pinput) Then
                MsgBox(0,"成功","欢迎使用")
                GUISetState(@sw_hide,$sform)
                                Return 1
        EndIf
EndFunc
发表于 2014-2-24 22:42:37 | 显示全部楼层
还有一点请教下,为啥我发的代码不像一楼那么好看是彩色的?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 23:26 , Processed in 0.076232 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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