MirnesC2 Posted September 25, 2009 Share Posted September 25, 2009 How do I limit what is being put into an input box? For example if I only wanted numbers in one input box, only letters in one input box, no symbols, maximum/minimum characters, and etc. ? Link to comment Share on other sites More sharing options...
Hawkwing Posted September 25, 2009 Share Posted September 25, 2009 For numbers you can use $ES_NUMBER, I'm not sure how to limit other stuff though. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
DW1 Posted September 25, 2009 Share Posted September 25, 2009 I can't help but think there is a much easier way to do this, but here are two examples from one very tired person, but they should work. expandcollapse popup#include <GUIConstantsEx.au3> $GUI = GUICreate("GUI", 300, 70) $Input1 = GUICtrlCreateInput("123Input123", 10, 10, 230, 20) $Input2 = GUICtrlCreateInput("123Input123", 10, 40, 230, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch AlphaOnly1($Input1, $GUI) AlphaOnly2($Input2, $GUI) Sleep(10) WEnd Func AlphaOnly1($ctrl, $fgui) ; Waits until the control no longer has focus $control = ControlGetFocus($fgui) If Not IsDeclared("focus") Then Global $focus = 0 If ControlGetHandle($fgui, '', $control) = GUICtrlGetHandle($ctrl) Then $focus = 1 EndIf If $focus = 1 And ControlGetHandle($fgui, '', $control) <> GUICtrlGetHandle($ctrl) Then $focus = 0 $data = GUICtrlRead($ctrl) $reg = StringRegExp($data, '[[:alpha:] ]', 3) $ret = '' For $a = 0 To UBound($reg) - 1 $ret &= $reg[$a] Next If $data <> $ret Then GUICtrlSetData($ctrl, $ret) Return 1 EndIf EndIf Return 0 EndFunc ;==>AlphaOnly Func AlphaOnly2($ctrl, $fgui) ; Always checking. Will move cursor to end of string if it changes the data $data = GUICtrlRead($ctrl) $reg = StringRegExp($data, '[[:alpha:] ]', 3) $ret = '' For $a = 0 To UBound($reg) - 1 $ret &= $reg[$a] Next If $data <> $ret Then GUICtrlSetData($ctrl, $ret) Return 1 EndIf Return 0 EndFunc ;==>AlphaOnly2 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
MirnesC2 Posted September 25, 2009 Author Share Posted September 25, 2009 Wow, that's more code than my entre program itself. Lol. Link to comment Share on other sites More sharing options...
DW1 Posted September 25, 2009 Share Posted September 25, 2009 Wow, that's more code than my entre program itself. Lol.Haha, yeah, I cannot help but think there is an easier obvious way to do this, but I can't seem to think of one... hopefully somebody will come by and show us a couple line example of how to accomplish this. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
MirnesC2 Posted September 25, 2009 Author Share Posted September 25, 2009 Yea, lol. I think Hawkwing might be on to something easier. Link to comment Share on other sites More sharing options...
DW1 Posted September 25, 2009 Share Posted September 25, 2009 Well $ES_NUMBER is the only limiting factor I see listed in the help file though... so I don't know if there will be an option for any other limiting factor. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now