Jump to content

Press enter while curser is located at input field


effer
 Share

Recommended Posts

How do you make a script able to accept an Enter press while the curser is located in an input field?

$user = GUICtrlCreateInput ( "", 150,  30, 50, 20)
$pass = GUICtrlCreateInput ( "", 150,  55, 70, 20, $ES_PASSWORD)
$ok = GUICtrlCreateButton("OK", 70, 80, 60)
GUICtrlSetOnEvent($ok, "saveinfo")
GUISetState(@SW_SHOW)

Func saveinfo()
    $login = GUICtrlRead($user)
    $code = GUICtrlRead($pass)
    GUIDelete();
EndFunc

When Enter is pressed, then the function saveinfo() should be run. How to do that?

/Effer

Link to comment
Share on other sites

How do you make a script able to accept an Enter press while the curser is located in an input field?

$user = GUICtrlCreateInput ( "", 150,  30, 50, 20)
$pass = GUICtrlCreateInput ( "", 150,  55, 70, 20, $ES_PASSWORD)
$ok = GUICtrlCreateButton("OK", 70, 80, 60)
GUICtrlSetOnEvent($ok, "saveinfo")
GUISetState(@SW_SHOW)

Func saveinfo()
    $login = GUICtrlRead($user)
    $code = GUICtrlRead($pass)
    GUIDelete();
EndFunc

When Enter is pressed, then the function saveinfo() should be run. How to do that?

/Effer

I assume that you want pressing enter to have the same effect as pushing the OK button. If this is correct you should look at $BS_DEFPUSHBUTTON. You will find it under GUI Control Styles Appendix in the help file.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

This has already been brought up a couple of times already, using the search feature can bring these up.

Any way, the way to do it is to put a very tiny button which gets activated when you hit enter.

Or allow a button to get pressed when enteris hit.

Like this:

$user = GUICtrlCreateInput ( "", 150,  30, 50, 20)
$pass = GUICtrlCreateInput ( "", 150,  55, 70, 20, $ES_PASSWORD)
$ok = GUICtrlCreateButton("OK", 70, 80, 60, 25, $BS_DEFPUSHBUTTON )
GUICtrlSetOnEvent($ok, "saveinfo")
GUISetState(@SW_SHOW)

Func saveinfo()
    $login = GUICtrlRead($user)
    $code = GUICtrlRead($pass)
    GUIDelete();
EndFunc

Look up $BS_DEFPUSHBUTTON in the help file.

EDIT: BigDod beat me to it!!!

Edited by nfwu
Link to comment
Share on other sites

you can look for _ispressed() function by ezzetabi.

$user = GUICtrlCreateInput ( "", 150,  30, 50, 20)
$pass = GUICtrlCreateInput ( "", 150,  55, 70, 20, $ES_PASSWORD)
$ok = GUICtrlCreateButton("OK", 70, 80, 60, 25, $BS_DEFPUSHBUTTON )
GUISetState(@SW_SHOW)
;;;i took out GUIctrlsetonevent

if _Ispressed('0D') Then
saveinfo()
Endif

Func saveinfo()
    $login = GUICtrlRead($user)
    $code = GUICtrlRead($pass)
    GUIDelete();
EndFunc

http://www.autoitscript.com/forum/index.ph...wtopic=5760&hl=

Edited by NegativeNrG

[size=20]My File Upload[/size]Register at my site and upload.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...