Jump to content

Hotkey on a form


sshrum
 Share

Recommended Posts

I have a custom form with a combobox and 2 buttons (OK and Cancel). On launch, my form will place the focus on the combobox. I'd like it so once the user scrolls to what they want, they should be able to just press the ENTER key which in turn would envoke my $button_OK code.

Possible?

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

Possible?

From the FM:

#include <GUIConstants.au3>

GUICreate("My GUICtrlRead") ; will create a dialog box that when displayed is centered

$n1=GUICtrlCreateList ("", 10,10,-1,100 )

GUICtrlSetData(-1,"item1|item2|item3", "item2")

$n2=GUICtrlCreateButton ("button",0,100)
GUICtrlSetState(-1,$GUI_FOCUS)      ; the focus is on this button

GUISetState ()    ; will display an empty dialog box
; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    if $msg = $n2 then
        msgbox(0,"list=", GUICtrlRead($n1)); display the value
    endif
Until $msg = $GUI_EVENT_CLOSE

This should get you started...

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

using beta _IsPressed function, the combo box can have focus and do what you want

#include <GUIConstants.au3>
#include <Misc.au3>

$Title = "My GUI combo"
GUICreate($Title) ; will create a dialog box that when displayed is centered

$cb_input = GUICtrlCreateCombo("item1", 10, 10); create first item
GUICtrlSetData(-1, "item2|item3", "item3"); add other item snd set a new default

$btn_Exit = GUICtrlCreateButton("Exit", 10, 40, 120, 20)

GUISetState()

$dll = DllOpen("user32.dll")
; Run the GUI until the dialog is closed
While 1
   $msg = GUIGetMsg()
   If _Monitor_InputBox($Title, $cb_input, $dll) Then $msg = $btn_Exit
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
  Case $msg = $btn_Exit
   MsgBox(0, "test", "User pressed enter")
   ExitLoop
   EndSelect
   
WEnd
DllClose($dll)

Func _Monitor_InputBox($Title, $cb_input, $dll)
   Local $WIN_SIZE
   $WIN_SIZE = WinGetClientSize($Title)
   If $WIN_SIZE[0] And $WIN_SIZE[1] Then
      If (ControlGetFocus($Title) = "Edit1") Then
         If _IsPressed ("0D", $dll) Then Return 1; user pressed enter key
      EndIf
   EndIf
EndFunc  ;==>_Monitor_InputBox
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...