EndFunc Posted March 10, 2009 Share Posted March 10, 2009 (edited) I'm trying to figure out how to have an input field to type in and have a button as the focus. So when I type I can hit enter and it excutes the button function. I tried looking at _GUICtrlButton_SetFocus but can't seem to get that to work. Anyone? Edited March 10, 2009 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
Spiff59 Posted March 10, 2009 Share Posted March 10, 2009 Maybe this button style will work for you: #include <ButtonConstants.au3> $Button_Find = GUICtrlCreateButton("FIND PATIENT", 400, 33, 96, 43, $BS_DEFPUSHBUTTON) Link to comment Share on other sites More sharing options...
EndFunc Posted March 10, 2009 Author Share Posted March 10, 2009 Maybe this button style will work for you: #include <ButtonConstants.au3> $Button_Find = GUICtrlCreateButton("FIND PATIENT", 400, 33, 96, 43, $BS_DEFPUSHBUTTON) That's cool, but still don't know how to make that work with an input field. I have the button physically next to the input field. Now, I'm trying to get it to be the focus so I can just hit enter but when using this style it doesn't set the focus. I must be doing something wrong. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
EndFunc Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) That's cool, but still don't know how to make that work with an input field. I have the button physically next to the input field. Now, I'm trying to get it to be the focus so I can just hit enter but when using this style it doesn't set the focus. I must be doing something wrong. Tried this and it wasn't very effective except once. Is there some sort of event handler that checks if you type anything in to the input it sets focus to the button. That sounds like what the style does but doesn't seem to work.$CheckID = GUICtrlCreateButton("Validate", 426, 140, 85, 21, 0)GUICtrlSetState($CheckID, $GUI_FOCUS) Edited March 10, 2009 by EndFunc Netol 1 EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
Spiff59 Posted March 11, 2009 Share Posted March 11, 2009 Is this the behavior you're after? #include <GUIConstants.au3> #include <ButtonConstants.au3> GUICreate("", 240, 80) $Input = GUICtrlCreateInput("", 20, 20, 120, 20) $Button = GUICtrlCreateButton("Button", 180, 20, 50, 20, $BS_DEFPUSHBUTTON) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button MsgBox(0, 'Testing', 'Button pressed') Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
sandin Posted March 11, 2009 Share Posted March 11, 2009 (edited) a bit off topic's title, but this is what you want, it detects ENTER on the input: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <WinAPI.au3> Global Const $VK_RETURN = 0x0D ;Enter key Global Const $GWL_WNDPROC = -4 $Form1 = GUICreate("Form1", 320, 30) $Input1 = GUICtrlCreateInput("", 5, 5, 210, 20) $Button1 = GUICtrlCreateButton("Button1", 220, 5, 95, 20) GUISetState(@SW_SHOW) Global $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") Global $wProc = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input1), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _WinAPI_SetWindowLong(GUICtrlGetHandle($Input1), $GWL_WNDPROC, $wProc) DllCallbackFree($wProcHandle) Exit Case $Button1 _some_action() EndSwitch WEnd func _some_action() TrayTip("", GUICtrlRead($Input1), 10) EndFunc Func _WindowProc($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $hWnd case GUICtrlGetHandle($Input1) Switch $iMsg Case $WM_GETDLGCODE Switch $wParam Case $VK_RETURN _some_action() ;or use: ;~ ControlClick($Form1, "", $Button1) ;but this will make you loose focus on the input EndSwitch EndSwitch EndSwitch Return _WinAPI_CallWindowProc($wProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc Edited March 11, 2009 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
CodyBarrett Posted March 11, 2009 Share Posted March 11, 2009 maybe... uhh i dont know if sandin's post does what you want, but i always use opt('guioneventmode',1) Guictrlsetonevent($Input,'Button_ok') it works fine for me UNLESS the input you have is a style that messes with the lines, i dont know why, but ^ that :S [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] 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