KXM Posted May 17, 2005 Share Posted May 17, 2005 Is there a way to have an edit field automaticly advance after x amount of chars (and 'devance' on backspace) like in the key entry feilds of program installers? If so any tips or pointers would be greatly welcomed. TIA. Link to comment Share on other sites More sharing options...
jdickens Posted May 20, 2005 Share Posted May 20, 2005 (edited) THIS IS MERELY PSEUDOCODE. IT WILL BE WRONG AS A SCRIPT AS IS $msg = GUIGetMsg() Select Case ($msg = $QuitBtn) OR ($msg = $GUI_EVENT_CLOSE) QuitBtnClick() Case $msg = $SpareBtn SpareBtnClick() Case $msg = $SubmitBtn IF CodeIsValid ($SecCode) THEN ;Exit This Loop Case $msg = $SecCode1 $SecCodePart1 = String(GUICtrlRead($SecCode1)) If StringLen($SecCodePart1) = $ValidLen Then ControlFocus($MyGUITitle, "", $SecCode2) Case $msg = $SecCode2 $SecCodePart2 = String(GUICtrlRead($SecCode2)) If StringLen($SecCodePart2) = $ValidLen Then ControlFocus($MyGUITitle, "", $SecCode3) ;etc. Case $msg = $SecCode5;LAST EDIT BOX $SecCodePart5 = String(GUICtrlRead($SecCode5)) If StringLen($SecCodePart5) = $ValidLen Then $SecCode = String(GUICtrlRead($SecCode1)) & String(GUICtrlRead($SecCode2)) ;etc. EndSelect J Edited May 20, 2005 by jdickens If I am too verbose, just say so. You don't need to run on and on. Link to comment Share on other sites More sharing options...
KXM Posted May 24, 2005 Author Share Posted May 24, 2005 (edited) First, and foremost, thanks! I tried what you suggusted (in autoit friedly code) but for reasions I can't understand the case loop dosen't seem to reconize when the second control if foucsed IE: $validlen = 4 Case $msg = $SecCode1 $SecCodePart1 = String(GUICtrlRead($SecCode1)) If StringLen($SecCodePart1) = $ValidLen Then ControlFocus($MyGUITitle, "", $SecCode2) Case $msg = $SecCode2 $SecCodePart2 = String(GUICtrlRead($SecCode2)) If StringLen($SecCodePart2) = $ValidLen Then ControlFocus($MyGUITitle, "", $SecCode3) Will focus control 2 on success, but will not do the same for contel 2 to 3. i've tried variations on the coder including some contenueloop and msgboxs. And I've concluded the the sceond control's case isn't being reconized. IE: $validlne = 4 Case $msg = $SecCode1 $SecCodePart1 = String(GUICtrlRead($SecCode1)) If StringLen($SecCodePart1) = $ValidLen Then ControlFocus($MyGUITitle, "", $SecCode2) Case $msg = $SecCode2 MsgBox(0,"","Control 2 case started") $SecCodePart2 = String(GUICtrlRead($SecCode2)) If StringLen($SecCodePart2) = $ValidLen Then ControlFocus($MyGUITitle, "", $SecCode3) Will not show a message box. Any ideas? Edited May 24, 2005 by KXM Link to comment Share on other sites More sharing options...
KXM Posted May 29, 2005 Author Share Posted May 29, 2005 Any one? TIA. Link to comment Share on other sites More sharing options...
Lazycat Posted May 29, 2005 Share Posted May 29, 2005 I'm trying to solve this, here results. Probably need some tweaks but basically works. expandcollapse popup#include <GUIConstants.au3> Dim $ahEdit[3] $hGUI = GUICreate("Window Title",260,250) $ahEdit[0] = GUICtrlCreateInput("", 5, 5, 40, 20) GUICtrlSetLimit (-1, 5) $ahEdit[1] = GUICtrlCreateInput("", 50, 5, 40, 20) GUICtrlSetLimit (-1, 5) $ahEdit[2] = GUICtrlCreateInput("", 95, 5, 40, 20) GUICtrlSetLimit (-1, 5) $nCurEdit = 0 GUISetState() While 1 $ip = _IsPressedMod() If $ip > 0 Then $res = GUICtrlRead($ahEdit[$nCurEdit]) If (StringLen($res) = 5) and not ($ip = 8) Then If $nCurEdit = UBound($ahEdit) - 1 Then ContinueLoop $nCurEdit = $nCurEdit + 1 GUICtrlSetState($ahEdit[$nCurEdit], $GUI_FOCUS) ContinueLoop Endif If (StringLen($res) = 0) and ($ip = 8) Then If $nCurEdit = 0 Then ContinueLoop $nCurEdit = $nCurEdit - 1 GUICtrlSetState($ahEdit[$nCurEdit], $GUI_FOCUS) GUICtrlSetData($ahEdit[$nCurEdit], GUICtrlRead($ahEdit[$nCurEdit])); Stupid trick but works ContinueLoop Endif Endif $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func _IsPressedMod() Local $aR, $bRv For $i = 8 to 128 $hexKey = '0x' & Hex($i, 2) $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If $aR[0] <> 0 Then Return $i Next Return 0 EndFunc Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
KXM Posted May 31, 2005 Author Share Posted May 31, 2005 (edited) Kick ass, it even goes backwards! THNX so much, I will try this as soon as I get home! Edited May 31, 2005 by KXM Link to comment Share on other sites More sharing options...
KXM Posted June 1, 2005 Author Share Posted June 1, 2005 Works like a charm!!! THNX so much! Link to comment Share on other sites More sharing options...
Michel Claveau Posted June 26, 2005 Share Posted June 26, 2005 Hi ! Few keys are not "view" by the code : ² ) = ù etc. I use a keyboard AZERTY (french) Is it normal ? Link to comment Share on other sites More sharing options...
Michel Claveau Posted June 26, 2005 Share Posted June 26, 2005 Hi ! Few keys are not "view" by the code : ² ) = ù etc.I use a keyboard AZERTY (french)Is it normal ?<{POST_SNAPBACK}>ReI have found. It's ok with : Func _IsPressedMod() Local $aR, $bRv For $i = 8 to 255 $hexKey = '0x' & Hex($i, 2) $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If $aR[0] <> 0 Then Return $i Next Return 0 EndFunc(128 --> 255)Good night ! Link to comment Share on other sites More sharing options...
Swimming_Bird Posted July 7, 2005 Share Posted July 7, 2005 I'm trying to solve this, here results. Probably need some tweaks but basically works.expandcollapse popup#include <GUIConstants.au3> Dim $ahEdit[3] $hGUI = GUICreate("Window Title",260,250) $ahEdit[0] = GUICtrlCreateInput("", 5, 5, 40, 20) GUICtrlSetLimit (-1, 5) $ahEdit[1] = GUICtrlCreateInput("", 50, 5, 40, 20) GUICtrlSetLimit (-1, 5) $ahEdit[2] = GUICtrlCreateInput("", 95, 5, 40, 20) GUICtrlSetLimit (-1, 5) $nCurEdit = 0 GUISetState() While 1 $ip = _IsPressedMod() If $ip > 0 Then $res = GUICtrlRead($ahEdit[$nCurEdit]) If (StringLen($res) = 5) and not ($ip = 8) Then If $nCurEdit = UBound($ahEdit) - 1 Then ContinueLoop $nCurEdit = $nCurEdit + 1 GUICtrlSetState($ahEdit[$nCurEdit], $GUI_FOCUS) ContinueLoop Endif If (StringLen($res) = 0) and ($ip = 8) Then If $nCurEdit = 0 Then ContinueLoop $nCurEdit = $nCurEdit - 1 GUICtrlSetState($ahEdit[$nCurEdit], $GUI_FOCUS) GUICtrlSetData($ahEdit[$nCurEdit], GUICtrlRead($ahEdit[$nCurEdit])); Stupid trick but works ContinueLoop Endif Endif $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func _IsPressedMod() Local $aR, $bRv For $i = 8 to 128 $hexKey = '0x' & Hex($i, 2) $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If $aR[0] <> 0 Then Return $i Next Return 0 EndFunc<{POST_SNAPBACK}>i'm sorry but i'm having a horrid time trying to figure out wtf is going on with this.I guess to start off with what does the _IsPressedMod function do? I understand that the two if loops are what actually advance the fous forward and back but i'm not sure how any of that is determinedthx for helpPS i'm trying to make a phone number entry for a gui of mine and not all of the fields would have the same number of chars. ie they will be 3-3-4 and 2-2-2-4 (number of chars in each input) Link to comment Share on other sites More sharing options...
Lazycat Posted July 8, 2005 Share Posted July 8, 2005 I guess to start off with what does the _IsPressedMod function do? I understand that the two if loops are what actually advance the fous forward and back but i'm not sure how any of that is determinedThis checks if one of keys with scancode from 8 to 128 is pressed (you can use all range from 0 to 255, but this is redundant imo), and in this case return pressed key code. It's used for determine that something changed in the field and for checking if backspace is pressed.PS i'm trying to make a phone number entry for a gui of mine and not all of the fields would have the same number of chars. ie they will be 3-3-4 and 2-2-2-4 (number of chars in each input)I use StringLen($res) = 5 for checking fixed length (5), but in your case you can make array with the field lengths (or use additional dimension in the $ahEdit for keep this) and compare length with it's values. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) 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