可以使用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
|