Jump to content

ctrlset focus


Recommended Posts

hi,

i have this gui and i would like when i press enter key button to display msgbox and the value of inputbox.

I have set GUI_FOCUS on the inputbox when gui SHOW but i don't know to display msgbox when i press enter key

HotKeySet ("{ENTER}) is not applicable because i have a lot of button

thanks

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 447, 310, 193, 115)
$Input1 = GUICtrlCreateInput("", 72, 96, 121, 21)
GUICtrlSetState(-1,$GUI_FOCUS)
$Button1 = GUICtrlCreateButton("&Press", 232, 96, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(0,"",GUICtrlRead($Input1))
        Case $Input1
            GUICtrlSetState($Button1,$GUI_FOCUS)
    EndSwitch
WEnd
Link to comment
Share on other sites

This works, sort of:

$Button1 = GUICtrlCreateButton("&Press", 232, 96, 75, 25, 0, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))

I say sort of because the first time you hit ENTER it just highlights the button. Every time thereafter it pops the message box even if focus is put back on the input. The alt-p works from the &Press too.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This works, sort of:

$Button1 = GUICtrlCreateButton("&Press", 232, 96, 75, 25, 0, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))

I say sort of because the first time you hit ENTER it just highlights the button. Every time thereafter it pops the message box even if focus is put back on the input. The alt-p works from the &Press too.

:)

tks, but the $Button1 = GUICtrlCreateButton("&Press", 232, 96, 75, 25, 0)

work also without the BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))

and the result is always the same...

in the 1st time I hit enter for 2 time to display a msgbox ;)

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