notta Posted October 15, 2007 Share Posted October 15, 2007 I created a custom gui with the an input box and a yes no button. By default the cursor is blinking in the inputbox like I want, but I also want the button defaulted to "yes" so the user only has to hit enter instead of moving the mouse to click ok. How can you set the focus on 2 items? $GUI_DEFBUTTON didn't help me out. Thanks. Link to comment Share on other sites More sharing options...
Nahuel Posted October 15, 2007 Share Posted October 15, 2007 Well... it's not $GUI_DEFBUTTON, it's $BS_DEFPUSHBUTTONTry this#include <GUIConstants.au3> GUICreate("", 292, 174, 211, 167) $Input1 = GUICtrlCreateInput("Write something here and press enter", 34, 40, 201, 21) $Button1 = GUICtrlCreateButton("Ok", 54, 102, 165, 35, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0,"","Hey it works! "&GUICtrlRead($Input1)) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Achilles Posted October 15, 2007 Share Posted October 15, 2007 As to your question, I do not think it is possible to have focus on two items. But Nahuel's solution should solve that problem. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
wolf9228 Posted October 15, 2007 Share Posted October 15, 2007 Well... it's not $GUI_DEFBUTTON, it's $BS_DEFPUSHBUTTON Try this #include <GUIConstants.au3> GUICreate("", 292, 174, 211, 167) $Input1 = GUICtrlCreateInput("Write something here and press enter", 34, 40, 201, 21) $Button1 = GUICtrlCreateButton("Ok", 54, 102, 165, 35, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0,"","Hey it works! "&GUICtrlRead($Input1)) EndSwitch WEnd or #include <GUIConstants.au3> $g =GUICreate("GUICreate", 292, 174, 211, 167) $Input1 = GUICtrlCreateInput("Write something here and press enter", 34, 40, 201, 21) $Button1 = GUICtrlCreateButton("Ok", 54, 102, 165, 35) GUISetState(@SW_SHOW) GUICtrlSetState ($Button1, $GUI_FOCUS ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0,"","Hey it works! "&GUICtrlRead($Input1)) EndSwitch WEnd صرح السماء كان هنا Link to comment Share on other sites More sharing options...
Nahuel Posted October 15, 2007 Share Posted October 15, 2007 or #include <GUIConstants.au3> $g =GUICreate("GUICreate", 292, 174, 211, 167) $Input1 = GUICtrlCreateInput("Write something here and press enter", 34, 40, 201, 21) $Button1 = GUICtrlCreateButton("Ok", 54, 102, 165, 35) GUISetState(@SW_SHOW) GUICtrlSetState ($Button1, $GUI_FOCUS ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0,"","Hey it works! "&GUICtrlRead($Input1)) EndSwitch WEnd No no, you see, the button gains focus at first run and it works if you press enter. But you have to click in the input box to be able to type and then the button loses focus.... 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