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

[AU3基础] 【已解决】运行软件要输密码,要怎样才能实现按回车健提交密码?

[复制链接]
发表于 2011-2-24 13:09:08 | 显示全部楼层 |阅读模式
本帖最后由 kood481748 于 2011-2-24 13:44 编辑

如图:运行软件要输密码,要怎样才能实现按回车健提交密码?

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Global $Input0, $Input1, $Edit1, $cancel, $start
Opt("TrayIconHide",0)

GUICreate("输入密码",380,230)
$text =    GUICtrlCreateLabel("请输入软件运行密码!", 50, 30, 280, 30)
GUICtrlSetFont($text, 21, 400, 1, "楷体_GB2312")
GUICtrlSetColor($text, 0xff0000)
$Input0 = GUICtrlCreateInput("", 100, 80, 180, 30, $ES_PASSWORD)
GUICtrlSetFont($input0, 15, 400, 1, "楷体_GB2312")
GUICtrlSetColor($input0, 0xff0000)

$start  = GUICtrlCreateButton("确定", 135, 165, 55, 25, 0)
$cancel = GUICtrlCreateButton("取消", 195, 165, 55, 25, 0)
GUISetState(@SW_SHOW)

Func OK()
        If GUICtrlRead($Input0) <> "123" Then
                MsgBox(64, "错误", "请正确输入密码……", 10)
                Return
        Else
                MsgBox(64, "正确", "密码验证成功……", 10)
        EndIf
EndFunc

While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then Exit
        If $msg = $cancel Then Exit
        If $msg = $start  Then OK()
WEnd

本帖子中包含更多资源

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

×
发表于 2011-2-24 13:16:26 | 显示全部楼层
15行,改为:$start  = GUICtrlCreateButton("确定", 135, 165, 55, 25, $BS_DEFPUSHBUTTON )

评分

参与人数 1金钱 +20 收起 理由
kood481748 + 20 谢谢面具人老师!

查看全部评分

发表于 2011-2-24 13:20:11 | 显示全部楼层
简单点,发个TAB然后再发个回车就OK了
发表于 2011-2-24 13:30:53 | 显示全部楼层
可以使用BS_DEFPUSHBUTTON式样或加速键

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Global $Input0, $Input1, $Edit1, $cancel, $start
Opt("TrayIconHide",0)
 
$hGui = GUICreate("输入密码",380,230)
$text =    GUICtrlCreateLabel("请输入软件运行密码!", 50, 30, 280, 30)
GUICtrlSetFont($text, 21, 400, 1, "楷体_GB2312")
GUICtrlSetColor($text, 0xff0000)
$Input0 = GUICtrlCreateInput("", 100, 80, 180, 30, $ES_PASSWORD)
GUICtrlSetFont($input0, 15, 400, 1, "楷体_GB2312")
GUICtrlSetColor($input0, 0xff0000)
 
$start  = GUICtrlCreateButton("确定", 135, 165, 55, 25, 0x0001);BS_DEFPUSHBUTTON 
$cancel = GUICtrlCreateButton("取消", 195, 165, 55, 25, 0)
GUISetState(@SW_SHOW)
;Local $AccelKeys[1][2]=[["{ENTER}", $start]]
;GUISetAccelerators($AccelKeys)
;加速键
 
Func OK()
        If GUICtrlRead($Input0) <> "kood465016143667" Then
                MsgBox(64, "错误", "请正确输入密码……", 10)
                Return
        Else
                MsgBox(64, "正确", "密码验证成功……", 10)
        EndIf
EndFunc
 
While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then Exit
        If $msg = $cancel Then Exit
        If $msg = $start  Then OK()
WEnd

评分

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

查看全部评分

发表于 2011-2-24 13:35:29 | 显示全部楼层
也可以这样
$start = GUICtrlCreateButton("确定", 135, 165, 55, 25)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

评分

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

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-2 14:39 , Processed in 0.078186 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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