Jump to content
Sign in to follow this  
grakker

Tab vs Return Input Control

Recommended Posts

grakker

I have a GUI with several fields. I would like to be able to have the {ENTER} key send a {TAB} until the

$submit = GUICtrlCreateButton("Submit", 260, 91, 110, 20)
button is active, at which point, just submit the deal and process.

My code works fine, aside from having to tab.

I've tried CASEing it, but that didn't work. I tried a HotKeySet.

I feel like I'm missing something obvious, but I've been banging my head here. It would just make data entry a lot faster....

Share this post


Link to post
Share on other sites
CyberSlug

This is a workaround.... I don't know the best way to determine if a control has focus....

$GUI = GuiCreate("Example")
GuiCtrlCreateButton("one",   10,  10, 100, 20)
GuiCtrlCreateButton("two",   10,  40, 100, 20)
GuiCtrlCreateButton("three", 10,  70, 100, 20)
$submit = GuiCtrlCreateButton("Submit",10, 100, 100, 20)

GuiSetState()
While 1
   If WinActive($GUI) Then
      HotKeySet("{Enter}", "SimulateTab")
   Else
      HotKeySet("{Enter}");unregister global hotkey when GUI not active
   EndIf
   
   $msg = GuiGetMsg()
   Select
   Case $msg = -3
      ExitLoop
   Case $msg = $submit
      MsgBox(4096,"","You clicked submit")
   EndSelect
WEnd
Exit

Func SimulateTab()
   If WinActive($GUI) And ControlGetFocus($GUI) = "Button4" Then
      HotKeySet("{Enter}");unregister hotkey in case we call a MsgBoxs
      MsgBox(4096,"Info","You clicked submit")
   Else
      Send("{Tab}")
   EndIf
EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
grakker

This is a workaround....  I don't know the best way to determine if a control has focus....

Ahhh, thanks CyberSlug. I'll try this when I get into work in the morning. This is almost what I was doing, except I was trying to get the control status directly and it was just making a bad loop. Needed to step back. Thanks again.

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  

×