Sign in to follow this  
Followers 0
effer

Press enter while curser is located at input field

5 posts in this topic

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

Share this post


Link to post
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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

OK, $BS_DEFPUSHBUTTON works.

I tried to use the search function, but I couldn't find anything (I didn't know, what words to search for :P )

Thanks for the answers

/Effer

Share this post


Link to post
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
Sign in to follow this  
Followers 0