Queener Posted May 15, 2014 Share Posted May 15, 2014 (edited) I'm kind of lost on how to code this; when the cursor focus in the input box or textbox and user press Enter, it calls a function. Only guess that I can think of is: While GUICtrlSetState($searchinput, $GUI_FOCUS) if send("{ENTER}") then testfunction() endif WEnd Edited May 15, 2014 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Damein Posted May 15, 2014 Share Posted May 15, 2014 (edited) I'm not sure about the input box ect. but here's how you can detect when they press enter. http://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm IE: #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("0D", $hDLL) Then MsgBox(0, "Test", "Enter was pressed") EndIf Sleep(250) WEnd Edited May 15, 2014 by Damein Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 15, 2014 Moderators Share Posted May 15, 2014 You can do this with Accelerators. Something like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> GUICreate("Test", 300, 300) $input = GUICtrlCreateInput("", 10, 10, 280, 100) Local $accelerators[1][2] $accelerators[0][0] = "{ENTER}" $accelerators[0][1] = $input GUISetAccelerators($accelerators) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $input MsgBox(0, "", "Enter Sent") EndSwitch WEnd GUIDelete() "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
JohnOne Posted May 17, 2014 Share Posted May 17, 2014 Without accelerators. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100, 20, $BS_DEFPUSHBUTTON) ;make default button $Button_2 = GUICtrlCreateButton("Button Test", 0, -1) GUICtrlCreateInput("", 10, -1, 200, 20); when ebter pressed with focus on input, acts like default button was pressed. and will in this case run notepad GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Run('notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_2 MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSelect WEnd EndFunc ;==>Example AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Gianni Posted May 17, 2014 Share Posted May 17, 2014 Also, have a look >here Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Solution Queener Posted May 29, 2014 Author Solution Share Posted May 29, 2014 thanks for the info, but this works well for me. I got from searching the forum... Local $nMsg[5] While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE _Exit() Case $ExitB1 _Exit() Case $searchinput ;when press Enter, go to Func Search Search() EndSwitch WEnd Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") 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