找回密码
 加入
搜索
查看: 3656|回复: 4

[AU3基础] 判断INPUT的输入状态【已解决】

[复制链接]
发表于 2010-9-6 10:01:26 | 显示全部楼层 |阅读模式
本帖最后由 woeiwoei 于 2010-9-6 10:35 编辑
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TEST", 394, 132, 192, 114)
$Input=GUICtrlCreateInput("", 112, 32, 121, 21)
$Input2=GUICtrlCreateInput("", 112, 80, 121, 21,0x0020)
$Button1 = GUICtrlCreateButton("保存", 256, 32, 75, 25)
$Button2 = GUICtrlCreateButton("重置", 256, 80, 75, 25)
$Label1 = GUICtrlCreateLabel("账号:", 80, 39, 30, 17)
$Label2 = GUICtrlCreateLabel("密码:", 80, 86, 30, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        BAOCUN()
                        panduan()
                        pand()
                        quanbu()
        Case $Button2
                        chongzhi() 
        EndSwitch
WEnd
Func BAOCUN()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
If $PUT1 ='' And $PUT2="" Then
MsgBox(64,"提示","请填写账号和密码")
Return
EndIf
EndFunc

Func panduan()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
If $PUT2<>"" And $PUT1="" Then 
MsgBox(64,"提示","请填写账号")
Return
EndIf
EndFunc

Func pand()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
        If $PUT1<>"" And $PUT2="" Then 
        MsgBox(64,"提示","请填写密码")
        Return
EndIf
EndFunc

Func quanbu()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
If $PUT1 <>'' And $PUT2<>"" Then
MsgBox(64,"提示","您的   账号为:"&$PUT1&"    密码为:"&$PUT2&"   如要修改请点重置!")
GUICtrlSetState($Input,$GUI_DISABLE)
GUICtrlSetState($Input2,$GUI_DISABLE)
EndIf
EndFunc

Func chongzhi() 
GUICtrlSetState($Input,$GUI_ENABLE)
GUICtrlSetState($Input2,$GUI_ENABLE)
GUICtrlSetData($Input,"")
GUICtrlSetData($Input2,"")
MsgBox(64,"提示","数据已重置!")
EndFunc
试验了半天也只能用这个方法了。那位大大能给优化下吗?还有其他方法去判断?

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-9-6 10:25:31 | 显示全部楼层
应该用不了这么多函数。简单改了一下,你试试:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TEST", 394, 132, 192, 114)
$Input = GUICtrlCreateInput("", 112, 32, 121, 21)
$Input2 = GUICtrlCreateInput("", 112, 80, 121, 21, 0x0020)
$Button1 = GUICtrlCreateButton("保存", 256, 32, 75, 25)
$Button2 = GUICtrlCreateButton("重置", 256, 80, 75, 25)
$Label1 = GUICtrlCreateLabel("账号:", 80, 39, 30, 17)
$Label2 = GUICtrlCreateLabel("密码:", 80, 86, 30, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        BAOCUN()
                        ;panduan()
                        ;pand()
                        ;quanbu()
                Case $Button2
                        chongzhi()
        EndSwitch
WEnd
Func BAOCUN()
        $PUT1 = GUICtrlRead($Input)
        $PUT2 = GUICtrlRead($Input2)
        If $PUT1 <> '' And $PUT2 <> "" Then
                MsgBox(64, "提示", "您的   账号为:" & $PUT1 & "    密码为:" & $PUT2 & "   如要修改请点重置!")
                GUICtrlSetState($Input, $GUI_DISABLE)
                GUICtrlSetState($Input2, $GUI_DISABLE)
        Else
                If $PUT1 = '' And $PUT2 = "" Then
                        MsgBox(64, "提示", "请填写账号和密码")
                ElseIf $PUT1 <> '' Then
                        MsgBox(64, "提示", "请填写密码")
                ElseIf $PUT2 <> '' Then
                        MsgBox(64, "提示", "请填写账号")
                EndIf
        EndIf
EndFunc   ;==>BAOCUN


Func chongzhi()
        GUICtrlSetState($Input, $GUI_ENABLE)
        GUICtrlSetState($Input2, $GUI_ENABLE)
        GUICtrlSetData($Input, "")
        GUICtrlSetData($Input2, "")
        MsgBox(64, "提示", "数据已重置!")
EndFunc   ;==>chongzhi

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-9-6 10:35:09 | 显示全部楼层
回复 2# 3mile


    哈哈哈  学习了。。怪我基础不好。。。非常感谢你。。。
发表于 2010-9-7 01:57:53 | 显示全部楼层
测试代码中
发表于 2010-9-7 18:35:24 | 显示全部楼层
学习,,谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-3 08:17 , Processed in 0.091441 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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