ttleser Posted March 30, 2009 Share Posted March 30, 2009 I found this thread >> http://www.autoitscript.com/forum/index.ph...eateinput+limitthat explained how to limit the characters typed in one field to just numbers and a decimal point, but what if you've got multiple fields you want to limit it to? Link to comment Share on other sites More sharing options...
Authenticity Posted March 31, 2009 Share Posted March 31, 2009 You mean multiple line or multiple inputs? expandcollapse popup#include <Constants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Dim $hGUI = GUICreate('Test', 200, 400) Dim $Inputs[12], $hInputs[12], $hWndProc[12] Dim $hFunc = DllCallbackRegister('WndProc', 'long', 'hwnd;uint;wparam;lparam') Dim $pFunc = DllCallbackGetPtr($hFunc) For $i = 0 To 11 $Inputs[$i] = GUICtrlCreateInput('', 0, $i*32+5, 200, 23) $hInputs[$i] = GUICtrlGetHandle(-1) $hWndProc[$i] = _WinAPI_GetWindowLong($hInputs[$i], $GWL_WNDPROC) _WinAPI_SetWindowLong($hInputs[$i], $GWL_WNDPROC, $pFunc) Next GUISetState() Do Sleep(20) Until GUIGetMsg() = -3 GUIDelete() DllCallbackFree($hFunc) Func WndProc($hWnd, $iMsg, $iwParam, $ilParam) Local $hWindowProc If $iMsg = $WM_CHAR Then If Not StringRegExp(Chr($iwParam), '\.|\d') Then Return 0 EndIf For $i = 0 To 11 $hWindowProc = $hWndProc[$i] If $hWnd = $hInputs[$i] Then ExitLoop Next Return _WinAPI_CallWindowProc($hWindowProc, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc For multiple inputs. Link to comment Share on other sites More sharing options...
GEOSoft Posted March 31, 2009 Share Posted March 31, 2009 (edited) If the controls are placed consecutivly in the GUI then run them through a for / Next loop $Frm_Main = GUICreate("Test Window") $In_1 = GUICtrlCreateInput("", 10, 10, 150, 20) $In_2 = GUICtrlCreateInput("", 10, 40, 150, 20) $In_3 = GUICtrlCreateInput("", 10, 70, 150, 20) $In_4 = GUICtrlCreateInput("", 10, 100, 150, 20) GUISetState() While 1 $Msg = GUIGetMsg() For $i = $in_1 To $In_4 If GUICtrlRead($i) <> "" Then $sChr = StringRight(GUICtrlRead($i), 1) If NOT StringRegExp($sChr, "\d|\.") Then GUICtrlSetData($i, StringTrimRight(GUICtrlRead($i), 1)) EndIf Next Switch $msg Case -3 ExitLoop Case Else EndSwitch Wend Edited March 31, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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