Validation 如何强制用户输入内容?
有没有办法强迫用户在使用“确定”按钮之前输入一些内容?例如: 我们使用字符Validation 如何强制用户输入内容?,validation,user-interface,autoit,Validation,User Interface,Autoit,有没有办法强迫用户在使用“确定”按钮之前输入一些内容?例如: 我们使用字符“M”。如果有,我将如何做 …在按下GUICtrlCreateInput中的OK按钮之前,是否强制用户输入内容 示例使用: 示例使用: 定义“强制用户输入内容”;预填充输入框,输入无效时重新提示?“s第4个参数仅接受单个字符(它直观地屏蔽输入的文本)。设置为“M”无效。顺便说一句,如果我对数字输入使用$ES_NUMBER而不是长字符串regexp(),会更容易吗?@Yay-Yes(控件样式提供的用途通常不需要它的潜力)。
“M”
。如果有,我将如何做
…在按下GUICtrlCreateInput中的OK按钮之前,是否强制用户输入内容
示例使用:
示例使用:
定义“强制用户输入内容”;预填充输入框,输入无效时重新提示?“s第4个参数仅接受单个字符(它直观地屏蔽输入的文本)。设置为
“M”
无效。顺便说一句,如果我对数字输入使用$ES_NUMBER而不是长字符串regexp(),会更容易吗?@Yay-Yes(控件样式提供的用途通常不需要它的潜力)。
InputBox("Sample", "Input Something:", "", " M", -1, -1)
Global Const $g_sPromt = 'Input something:'
Global Const $g_sChar = '*'
Global Const $g_sDefault = 'something'
Global $g_sInput = ''
While Not $g_sInput Or $g_sInput = $g_sDefault
$g_sInput = InputBox(@ScriptName, $g_sPromt, $g_sDefault, $g_sChar)
WEnd
ConsoleWrite($g_sInput & @CRLF)
#include <GUIConstantsEx.au3>
Global Const $g_iGuiMargin = 10
Global Const $g_iGuiSizeH = $g_iGuiMargin * 2
Global Const $g_iGuiWidth = 200
Global Const $g_iGuiHeight = ($g_iGuiSizeH * 2) + ($g_iGuiMargin * 3)
Global Const $g_sInpText = 'Input something:'
Global Const $g_sInpDefault = 'something'
Global Const $g_iInpLeft = $g_iGuiMargin
Global Const $g_iInpTop = $g_iInpLeft
Global Const $g_iInpWidth = $g_iGuiWidth - ($g_iInpLeft * 2)
Global Const $g_iInpHeight = $g_iGuiSizeH
Global Const $g_sBtnText = 'OK'
Global Const $g_iBtnLeft = $g_iInpLeft
Global Const $g_iBtnTop = $g_iInpHeight + $g_iInpTop + $g_iGuiMargin
Global Const $g_iBtnWidth = $g_iInpWidth
Global Const $g_iBtnHeight = $g_iGuiSizeH
Global $g_sInput = ''
Global $g_hGui
Global $g_hInput
Global $g_hButton
$g_hGui = GUICreate(@ScriptName, $g_iGuiWidth, $g_iGuiHeight)
$g_hInput = GUICtrlCreateInput($g_sInpText, $g_iInpLeft, $g_iInpTop, $g_iInpWidth, $g_iInpHeight)
$g_hButton = GUICtrlCreateButton($g_sBtnText, $g_iBtnLeft, $g_iBtnTop, $g_iBtnWidth, $g_iBtnHeight)
GUICtrlSetData($g_hInput, $g_sInpDefault)
GUISetState(@SW_SHOW, $g_hGui)
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $g_hButton
$g_sInput = GUICtrlRead($g_hInput)
If Not $g_sInput Or $g_sInput = $g_sInpDefault Then
SoundPlay(@WindowsDir & "\media\Windows Background.wav")
GUICtrlSetData($g_hInput, $g_sInpDefault)
ContinueLoop
Else
ConsoleWrite($g_sInput & @CRLF)
GUIDelete($g_hGui)
Exit
EndIf
EndSwitch
WEnd
If Not $g_sInput Or $g_sInput = $g_sInpDefault Or Not StringRegExp($g_sInput, '^\d$') Then