Jump to content



Photo

GUICtrlCreateInput onevent= enter


  • Please log in to reply
5 replies to this topic

#1 DearNoBody

DearNoBody

    Seeker

  • New Members
  • 2 posts

Posted 16 May 2009 - 10:30 PM

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





#2 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,199 posts

Posted 16 May 2009 - 11:23 PM

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

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

  • matwachich likes this
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.

#3 DearNoBody

DearNoBody

    Seeker

  • New Members
  • 2 posts

Posted 17 May 2009 - 12:18 AM

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

#4 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,199 posts

Posted 01 June 2009 - 10:28 PM

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
Plain Text         
#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.

#5 MilesAhead

MilesAhead

    Eclectician

  • Active Members
  • PipPipPipPipPipPip
  • 531 posts

Posted 02 June 2009 - 12:10 AM

I wondered why they had that dummy control. Good to see how to use it. :)
"I don't want to belong to any club that would have me as a member."- Groucho Marx

#6 Yibing

Yibing

    Seeker

  • Active Members
  • 6 posts

Posted 28 July 2009 - 01:43 PM

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

Plain Text         
#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()






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users