Sunaj Posted November 21, 2006 Share Posted November 21, 2006 (edited) Having trouble figuring out something (seemingly) very basic: How to allow a button to be clicked without setting it to have the default control focus (i.e. a black border line around it)?! Here is a basic GUI with some buttons that do nothing for demonstration. What is needed to allow the user to click a given button and have the GUI appear exactly as when it was opened.. ? #include <GUIConstants.au3> $MainGUI = GUICreate("example", 300, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState() $Button_1 = GUICtrlCreateButton ("Button1", 10, 30, 100) $Button_2 = GUICtrlCreateButton ("Button2", 10, 60, 100) $Button_3 = GUICtrlCreateButton ("Button3", 10, 90, 100) While 1 Sleep(10) Wend Func Close() Exit EndFunc Edited November 21, 2006 by Sunaj [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
GaryFrost Posted November 21, 2006 Share Posted November 21, 2006 Maybe something like: #include <GUIConstants.au3> $MainGUI = GUICreate("example", 300, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState() $Button_1 = GUICtrlCreateButton ("Button1", 10, 30, 100) GUICtrlSetOnEvent($Button_1, "Button_Event") $Button_2 = GUICtrlCreateButton ("Button2", 10, 60, 100) GUICtrlSetOnEvent($Button_2, "Button_Event") $Button_3 = GUICtrlCreateButton ("Button3", 10, 90, 100) GUICtrlSetOnEvent($Button_3, "Button_Event") $dummy = GUICtrlCreateDummy() While 1 Sleep(10) Wend Func Close() Exit EndFunc Func Button_Event() GUICtrlSetState($dummy, $GUI_FOCUS) EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Sunaj Posted November 22, 2006 Author Share Posted November 22, 2006 (edited) I reckon its the right kind of approach - it doesn't work though; the first button which is clicked after script is run retains the black edge despite the focus being set to the dummy in your code Maybe something like: #include <GUIConstants.au3> $MainGUI = GUICreate("example", 300, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState() $Button_1 = GUICtrlCreateButton ("Button1", 10, 30, 100) GUICtrlSetOnEvent($Button_1, "Button_Event") $Button_2 = GUICtrlCreateButton ("Button2", 10, 60, 100) GUICtrlSetOnEvent($Button_2, "Button_Event") $Button_3 = GUICtrlCreateButton ("Button3", 10, 90, 100) GUICtrlSetOnEvent($Button_3, "Button_Event") $dummy = GUICtrlCreateDummy() While 1 Sleep(10) Wend Func Close() Exit EndFunc Func Button_Event() GUICtrlSetState($dummy, $GUI_FOCUS) EndFunc Edited November 22, 2006 by Sunaj [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
MHz Posted November 22, 2006 Share Posted November 22, 2006 I reckon its the right kind of approach - it doesn't work though; the first button which is clicked after script is run retains the black edge despite the focus being set to the dummy in your code Add alittle style $BS_DEFPUSHBUTTON Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option, or default. #include <GUIConstants.au3> $MainGUI = GUICreate("example", 300, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState() $Button_1 = GUICtrlCreateButton ("Button1", 10, 30, 100, Default, $BS_DEFPUSHBUTTON) GUICtrlSetOnEvent(Default, 'fun') $Button_2 = GUICtrlCreateButton ("Button2", 10, 60, 100) $Button_3 = GUICtrlCreateButton ("Button3", 10, 90, 100) While 1 Sleep(10) Wend Func Close() Exit EndFunc Func fun() MsgBox(0, '', 'ok') EndFunc Link to comment Share on other sites More sharing options...
GaryFrost Posted November 22, 2006 Share Posted November 22, 2006 expandcollapse popup#include <GUIConstants.au3> $MainGUI = GUICreate("example", 300, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState() $Button_1 = GUICtrlCreateButton("Button1", 10, 30, 100) GUICtrlSetOnEvent($Button_1, "Button1_Event") $Button_2 = GUICtrlCreateButton("Button2", 10, 60, 100) GUICtrlSetOnEvent($Button_2, "Button2_Event") $Button_3 = GUICtrlCreateButton("Button3", 10, 90, 100) GUICtrlSetOnEvent($Button_3, "Button3_Event") $dummy = GUICtrlCreateButton("dummny", 10, 120, 100) GUICtrlSetState($dummy, $GUI_HIDE) While 1 Sleep(10) WEnd Func Close() Exit EndFunc ;==>Close Func Button1_Event() GUICtrlSetState($Button_1, $GUI_HIDE) GUICtrlSetState($dummy, $GUI_FOCUS) GUICtrlSetState($Button_1, $GUI_SHOW) EndFunc ;==>Button1_Event Func Button2_Event() GUICtrlSetState($Button_2, $GUI_HIDE) GUICtrlSetState($dummy, $GUI_FOCUS) GUICtrlSetState($Button_2, $GUI_SHOW) EndFunc ;==>Button2_Event Func Button3_Event() GUICtrlSetState($Button_3, $GUI_HIDE) GUICtrlSetState($dummy, $GUI_FOCUS) GUICtrlSetState($Button_3, $GUI_SHOW) EndFunc ;==>Button3_Event SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Sunaj Posted November 22, 2006 Author Share Posted November 22, 2006 Thanks gafrost, you really helped me out on this one! , the posted code completely solves the puzzle. The approach is rather esoteric; would never have thought of using GUICtrlSetState in that way myself.. Best, Sunaj expandcollapse popup#include <GUIConstants.au3> $MainGUI = GUICreate("example", 300, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState() $Button_1 = GUICtrlCreateButton("Button1", 10, 30, 100) GUICtrlSetOnEvent($Button_1, "Button1_Event") $Button_2 = GUICtrlCreateButton("Button2", 10, 60, 100) GUICtrlSetOnEvent($Button_2, "Button2_Event") $Button_3 = GUICtrlCreateButton("Button3", 10, 90, 100) GUICtrlSetOnEvent($Button_3, "Button3_Event") $dummy = GUICtrlCreateButton("dummny", 10, 120, 100) GUICtrlSetState($dummy, $GUI_HIDE) While 1 Sleep(10) WEnd Func Close() Exit EndFunc ;==>Close Func Button1_Event() GUICtrlSetState($Button_1, $GUI_HIDE) GUICtrlSetState($dummy, $GUI_FOCUS) GUICtrlSetState($Button_1, $GUI_SHOW) EndFunc ;==>Button1_Event Func Button2_Event() GUICtrlSetState($Button_2, $GUI_HIDE) GUICtrlSetState($dummy, $GUI_FOCUS) GUICtrlSetState($Button_2, $GUI_SHOW) EndFunc ;==>Button2_Event Func Button3_Event() GUICtrlSetState($Button_3, $GUI_HIDE) GUICtrlSetState($dummy, $GUI_FOCUS) GUICtrlSetState($Button_3, $GUI_SHOW) EndFunc ;==>Button3_Event [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] 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