kood481748 发表于 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 = $startThen OK()
WEnd

3mile 发表于 2011-2-24 13:16:26

15行,改为:$start= GUICtrlCreateButton("确定", 135, 165, 55, 25, $BS_DEFPUSHBUTTON )

acbs 发表于 2011-2-24 13:20:11

简单点,发个TAB然后再发个回车就OK了

ceoguang 发表于 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=[["{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 = $startThen OK()
WEnd

lixiaolong 发表于 2011-2-24 13:35:29

也可以这样
$start = GUICtrlCreateButton("确定", 135, 165, 55, 25)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
页: [1]
查看完整版本: 【已解决】运行软件要输密码,要怎样才能实现按回车健提交密码?