Fire Posted November 18, 2009 Share Posted November 18, 2009 Hi to all.I need small help.My trouble is how can i filter user input (ON GUI) mode.For example i want to allow only digits dont allow letter. How to do it?:$a = GUICtrlCreateInput("", 192, 144, 153, 21) GUICtrlSetLimit(-1, 12) [size="5"] [/size] Link to comment Share on other sites More sharing options...
Mat Posted November 18, 2009 Share Posted November 18, 2009 have you tried the $ES_NUMBER style? $ES_NUMBER | 0x2000 | Accepts into the edit control only digits to be typed. Edit styles can be used on inputs, as inputs are simply edits without the $ES_MULTILINE style. Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Fire Posted November 18, 2009 Author Share Posted November 18, 2009 Thanks Mat.I tried StringRegExpReplace() but pattern is very difficult for me using. Thanks for alternative method i would try it Thanks again. [size="5"] [/size] Link to comment Share on other sites More sharing options...
somdcomputerguy Posted November 18, 2009 Share Posted November 18, 2009 Or you use this Function StringIsDigit to check the input after it's been inputted. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 18, 2009 Share Posted November 18, 2009 You can add the $ES_NUMBER style to the input control: #include <GuiConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 200, 200) $idInput = GUICtrlCreateInput("", 20, 20, 160, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE But that doesn't allow negatives or decimal points, and you can't set limits on it. Perhaps you want an UpDown control instead? See the example in the help file under GUICtrlCreateUpdown(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Fire Posted November 18, 2009 Author Share Posted November 18, 2009 Or you use this Function StringIsDigit to check the input after it's been inputted.Thank you very much snowmaker.I learn this way too from you.And i understand that for inside out use StringIsAlpha(). (allow only alpahebitcal input)Than you very much PsaltyDS.Really Respects ++ [size="5"] [/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 18, 2009 Moderators Share Posted November 18, 2009 Sh3llC043r,If you want an input which will accept negatives and decimal points, here is one that will: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> GUICreate("Input Filter", 300, 30, -1, -1) Global $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIRegisterMsg($WM_COMMAND, "") Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord Local $iCode = BitShift($wParam, 16) ;HiWord If $iIDFrom = $inTest And $iCode = $EN_CHANGE Then $Read_Input = GUICtrlRead($inTest) If StringRegExp($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Input = StringRegExpReplace($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1') $Point1 = StringInStr($Read_Input, ".", 0) $Point2 = StringInStr($Read_Input, ".", 0, 2) If $Point2 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point2 - 1) If $Point1 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point1 + 2) GUICtrlSetData($inTest, $Read_Input) EndIf EndFunc;==>_WM_COMMANDIt is pretty easy to adapt to any munber of decimal places - an exercise for the student as my old maths master used to say! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
somdcomputerguy Posted November 18, 2009 Share Posted November 18, 2009 Thank you very much snowmaker.I learn this way too from you.I hope whatever method you use suits your needs. I'm not much of a coder at all, I learn by trying to help others, and usually my suggestions are not the best way, and sometimes they're just plain wrong.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Fire Posted November 18, 2009 Author Share Posted November 18, 2009 Sh3llC043r, If you want an input which will accept negatives and decimal points, here is one that will:Your code is Great.Than you very much too.I think all this post is sholud be very helpness for newbies as like me . Thanks to all for help #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> GUICreate("Input Filter", 300, 30, -1, -1) Global $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIRegisterMsg($WM_COMMAND, "") Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord Local $iCode = BitShift($wParam, 16) ;HiWord If $iIDFrom = $inTest And $iCode = $EN_CHANGE Then $Read_Input = GUICtrlRead($inTest) If StringRegExp($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Input = StringRegExpReplace($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1') $Point1 = StringInStr($Read_Input, ".", 0) $Point2 = StringInStr($Read_Input, ".", 0, 2) If $Point2 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point2 - 1) If $Point1 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point1 + 2) GUICtrlSetData($inTest, $Read_Input) EndIf EndFunc;==>_WM_COMMAND [size="5"] [/size] 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