Press Enter instead of tab and enter

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Press Enter instead of tab and enter

Post by kpassaur » Tue May 06, 2008 1:28 pm

I don't know if this is possible in MS. I have a simple dialog box just one field is in it, when the user enters the data they have to click on tab to go to the "OK" button for the script to continue. I have been asked to remove the need for hitting the tab key first.

So they would enter 123 and press Enter instead of entering 123 tab enter.

Also is there a way without the mouse move command for the cursor to be in a given edit box. In other words the user currently clicks on an icon to run the script, then they have to move their mouse into the edit box and then enter the data. It would be nice if when the dialog opened it had the cursor in the edit box already.

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Tue May 06, 2008 2:18 pm

Kpass,
JRL gave me a nice work around some time ago.. see if this helps..

Ed

http://www.mjtnet.com/usergroup/viewtop ... highlight=

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue May 06, 2008 2:29 pm

I answered a similar question a few days ago. See my reply here:
http://www.mjtnet.com/forum/viewtopic.php?p=20171

You can put the keyboard focus (and therefore the cursor) in any dialog field like this:

LibFunc>user32,SetFocus,r,DIALOG1.MSEDIT2.HANDLE
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue May 06, 2008 2:43 pm

kpassaur wrote:I have a simple dialog box just one field is in it....is there a way without the mouse move command for the cursor to be in a given edit box.
If you only have one edit box and one button this becomes very simple to accommodate. The order of the objects in the dialog block determines the order of their focus as you tab through the dialog. In other words if you want the edit box to have focus when the dialog is opened, make the edit box the first object defined in the dialog block.
kpassaur wrote:...when the user enters the data they have to click on tab to go to the "OK" button for the script to continue. I have been asked to remove the need for hitting the tab key first.
There is a "Default" feature in dialogs that allows you to set a button to be the default when enter is pressed and while focus is on an edit field.

Code: Select all

Dialog>Dialog1
   Caption=Demo
   Width=230
   Height=110
   Top=160
   Left=48
   //Edit box is first object defined and will take focus
   //when the dialog opens
   Edit=msEdit1,48,16,121,
   Button=Ok,72,48,75,25,3
   //Default states that pressing the Enter key will "press" the
   //Ok button without first tabbing to it.
   Default=Ok
EndDialog>Dialog1

Show>dialog1,res1

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Default button and focus also works on drop downs

Post by kpassaur » Tue May 06, 2008 2:55 pm

Thank you all it works great by putting them in order (each of these has only one box) and adding the line Default="Button Name". I have found that if instead of an edit box there is a drop down list they can use the down arrows and press enter.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts