DW1 Posted July 26, 2007 Share Posted July 26, 2007 I would like for a user to be able to click on an edit, type something, and press enter to "do" the action instead of having to click a button How would I do this? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
James Posted July 26, 2007 Share Posted July 26, 2007 (edited) #include <GUIConstants.au3> $GUI = GUICreate("", 162, 96, -1, -1) $Input = GUICtrlCreateInput("Type hello then hit enter!", 8, 8, 145, 21) $Send = GUICtrlCreateButton("&Send", 32, 40, 89, 41, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input If GuiCtrlRead($Input) = "Hello" Then MsgBox(4096, "Hello!", "You pressed the enter key!") EndIf Case $Send If GuiCtrlRead($Input) = "Hello" Then MsgBox(4096, "Hello!", "You pressed the send key!") EndIf EndSwitch WEnd That's a better example. -James Edited July 26, 2007 by NeoTroniX Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
DW1 Posted July 26, 2007 Author Share Posted July 26, 2007 That doesn't work, I don't have to press enter. I can just click on the edit. Any way to make sure that only ENTER triggers the event? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
nairada Posted July 26, 2007 Share Posted July 26, 2007 #include <GUIConstants.au3> $GUI = GUICreate("", 161, 37, -1, -1) $Input = GUICtrlCreateInput("Type hello then hit enter!", 8, 8, 145, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input If GuiCtrlRead($Input) = "Hello" Then MsgBox(4096, "Hello!", "You pressed the enter key!") EndIf EndSwitch WEnd Modified NeoTroniX's example. Is this more like what you want? Link to comment Share on other sites More sharing options...
DW1 Posted July 26, 2007 Author Share Posted July 26, 2007 This is more what I needed: DUH!! to me, I found this in the FAQ sticky HotKeySet("{ENTER}", "catchguikey") ; ;REST OF CODE HERE ; ; Func catchguikey() Local $opt = Opt("WinTitleMatchMode", 4) If WinGetHandle("active") = $DB Then If @HotKeyPressed = "{ENTER}" Then ;Do something here _IENavigate($oIE, GUICtrlRead( $manualaddy ), 0) EndIf Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "catchguikey") EndIf Opt("WinTitleMatchMode", $opt) EndFunc AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted July 26, 2007 Author Share Posted July 26, 2007 Thanks for the help though guys AutoIt3 Online Help Link to comment Share on other sites More sharing options...
James Posted July 27, 2007 Share Posted July 27, 2007 Isn't my way easier? Oh well, it works. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
DW1 Posted July 27, 2007 Author Share Posted July 27, 2007 sort of, your way will be triggered on a mouse click to the edit box as well as pressing enter, where as the one I used is ONLY for pressing enter Also I changed the code a bit so that the proper window and the proper control must be selected. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now