Jump to content
Sign in to follow this  
AustrianOak

Make a button press when I press enter

Recommended Posts

AustrianOak

I can't figure out how to make a button "think" it was pressed when I press the 'enter' key when typing in an input.

How can I accomplish this

Share this post


Link to post
Share on other sites
enaiman

GUICtrlSetState(-1, $GUI_DEFBUTTON) - will select that button so when you press Enter it will press that button.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 281, 142, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Input1 = GUICtrlCreateInput("Input1", 32, 32, 217, 21)
GUICtrlSetOnEvent(-1, "Input1Change")
$Button1 = GUICtrlCreateButton("Button1", 16, 96, 81, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 176, 96, 81, 25, 0)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()

EndFunc
Func Button2Click()
    MsgBox(0, "Info", "You have pressed Enter")
EndFunc
Func Form1Close()
    Exit
EndFunc
Func Input1Change()

EndFunc

Another way is: HotKeySet ( "key" [, "function"] )


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.