DearNoBody Posted May 16, 2009 Share Posted May 16, 2009 I have a gui input box for password and wanted to see if the user can just press enter rather than clicking a button I know on InputBox the user can enter text and press enter continue to the next step. Is it possible to do the same when using the GUICtrlCreateInput? Here's partial code: ;password GuiCtrlCreateLabel("Enter your directory password (optional):", 10, 55, 325, 20) $MyPassword = GUICtrlCreateInput("",10, 75, 350, 20, 0x00020) ;the 0x00020 creates the '*' while typing GUICtrlSetState(-1, $GUI_FOCUS) ;set button to default so user can just hit enter to accept defaults If $msg = $Save Then $MyPassword = GUICtrlRead($MyPassword) endif Currently the user must click on the Save button. Is there a way for the user to enter the password and press the enter key? Thanks. DNB Link to comment Share on other sites More sharing options...
martin Posted May 16, 2009 Share Posted May 16, 2009 I have a gui input box for password and wanted to see if the user can just press enter rather than clicking a button I know on InputBox the user can enter text and press enter continue to the next step. Is it possible to do the same when using the GUICtrlCreateInput? Here's partial code: ;password GuiCtrlCreateLabel("Enter your directory password (optional):", 10, 55, 325, 20) $MyPassword = GUICtrlCreateInput("",10, 75, 350, 20, 0x00020) ;the 0x00020 creates the '*' while typing GUICtrlSetState(-1, $GUI_FOCUS) ;set button to default so user can just hit enter to accept defaults If $msg = $Save Then $MyPassword = GUICtrlRead($MyPassword) endif Currently the user must click on the Save button. Is there a way for the user to enter the password and press the enter key? Thanks. DNBJust pressing Enter when the input has focus will cause an event from the input, so this example might be what you need. GUICreate("input with Enter") $ip1 = GUICtrlCreateInput("", 30, 40, 120, 22) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case - 3 Exit Case $ip1 MsgBox(262144, "ip1", "enter pressed") EndSwitch WEnd matwachich 1 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
DearNoBody Posted May 17, 2009 Author Share Posted May 17, 2009 Just pressing Enter when the input has focus will cause an event from the input, so this example might be what you need. GUICreate("input with Enter") $ip1 = GUICtrlCreateInput("", 30, 40, 120, 22) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case - 3 Exit Case $ip1 MsgBox(262144, "ip1", "enter pressed") EndSwitch WEnd Thank you. Sometimes it takes a second pair of eyes. --DNB Link to comment Share on other sites More sharing options...
martin Posted June 1, 2009 Share Posted June 1, 2009 Thank you. Sometimes it takes a second pair of eyes. --DNB In fact ENter will only trigger an event when there has been some change to the input. If you just click in the input and press Enter you probably won't trigger an event. Here is one way round that #include <GuiConstantsEx.au3> #include <windowsconstants.au3> $Gui = GUICreate("Edit Append Text", 400, 300) $Input1 = GUICtrlCreateInput("This is a test", 2, 2, 394, 26) $Ip2 = GUICtrlCreateInput("another one", 2, 35, 394, 26) $Dum = GUICtrlCreateDummy() Dim $accels[1][2] = [["{ENTER}", $Dum]] GUISetAccelerators($accels) GUISetState() ; GUIRegisterMsg($WM_COMMAND, "DB_WM_COMMAND");only used for EN_CHANGE so far GUICtrlSetData($Input1, "Append to the end?") ; Loop until user exits While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Input1 ConsoleWrite("edited" & @CRLF) Case $Dum If ControlGetFocus($Gui) = "Edit1" Then ConsoleWrite("Enter pressed in Edit1" & @CRLF) EndSwitch WEnd GUIDelete() Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
MilesAhead Posted June 2, 2009 Share Posted June 2, 2009 I wondered why they had that dummy control. Good to see how to use it. My Freeware Page Link to comment Share on other sites More sharing options...
Yibing Posted July 28, 2009 Share Posted July 28, 2009 Best Solution EVER!! Thanks a million! In fact ENter will only trigger an event when there has been some change to the input. If you just click in the input and press Enter you probably won't trigger an event. Here is one way round that #include <GuiConstantsEx.au3> #include <windowsconstants.au3> $Gui = GUICreate("Edit Append Text", 400, 300) $Input1 = GUICtrlCreateInput("This is a test", 2, 2, 394, 26) $Ip2 = GUICtrlCreateInput("another one", 2, 35, 394, 26) $Dum = GUICtrlCreateDummy() Dim $accels[1][2] = [["{ENTER}", $Dum]] GUISetAccelerators($accels) GUISetState() ; GUIRegisterMsg($WM_COMMAND, "DB_WM_COMMAND");only used for EN_CHANGE so far GUICtrlSetData($Input1, "Append to the end?") ; Loop until user exits While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Input1 ConsoleWrite("edited" & @CRLF) Case $Dum If ControlGetFocus($Gui) = "Edit1" Then ConsoleWrite("Enter pressed in Edit1" & @CRLF) EndSwitch WEnd GUIDelete() 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