Followers 0

# Last Button Clicked Focus

## 8 posts in this topic

I'm looking for a way to have that thickened black outline on the last button clicked to be removed, so that whenever you click a button, it still looks like all the other buttons.

##### Share on other sites

Hi sticky, it is ALWAYS best you you give an example script

8)

##### Share on other sites

This is a rather messy way of doing it (I just created a button that was off the GUI that gets the focus as soon as the button is pressed):

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

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)
$Button_2 = GUICtrlCreateButton("Button Test", 500, 500) 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
GuiCtrlSetSTate($Button_2,$GUI_FOCUS)
EndSelect
WEnd
EndFunc  ;==>Example

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

##### Share on other sites

This is a rather messy way of doing it (I just created a button that was off the GUI that gets the focus as soon as the button is pressed):

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

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)
$Button_2 = GUICtrlCreateButton("Button Test", 500, 500) 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
GuiCtrlSetSTate($Button_2,$GUI_FOCUS)
EndSelect
WEnd
EndFunc ;==>Example
Might be better of to use something like

$focus = GUICtrlCreateLabel("", 0, 0, 1, 1) and set the focus to that. Also I don't remember for sure if you can set focus on a Dummy or not, but that might be another option. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums. Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" #### Share this post ##### Link to post ##### Share on other sites Dummy didn't work, after trying this: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Local$Button_1, $dummy,$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)$dummy = GuictrlCreateDummy()

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 GuiCtrlSetState($dummy, $GUI_FOCUS) EndSelect WEnd My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] #### Share this post ##### Link to post ##### Share on other sites Dummy didn't work, after trying this: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Local$Button_1, $dummy,$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)$dummy = GuictrlCreateDummy()

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 GuiCtrlSetState($dummy, $GUI_FOCUS) EndSelect WEnd I had that feelig about Dummy but I couldn't remember for sure. The blank label will work though. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums. Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" #### Share this post ##### Link to post ##### Share on other sites #7 · Posted (edited) This is a rather messy way of doing it (I just created a button that was off the GUI that gets the focus as soon as the button is pressed): #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) 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)$Button_2 = GUICtrlCreateButton("Button Test", 500, 500)

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 GuiCtrlSetSTate($Button_2, $GUI_FOCUS) EndSelect WEnd EndFunc;==>Example I tried this idea and it half worked, if you look, the Run Notepad still has a slight blue outline on the button. I'm not using the Windows GUI buttons, but rather my own bmps as each button. Here's the main GUI code without any of the functions. The guifocus setting to the fake button is in the function call, instead of the select case. GuiCreate("Lighting Control", 400, 18, 400, 400,$WS_POPUP, $WS_DISABLED) GUICtrlCreateLabel("Projectors:",0,3,55,18) GUICtrlCreateLabel("Lights:",200,3,40,18) GUICtrlCreatePic("C:\Documents and Settings\projector\My Documents\AutoIt\bar.bmp", 190, 0, 2, 17) GUISetFont(8)$btn10 = GuiCtrlCreateButton("On", 60, 0, 40, 18, $BS_BITMAP)$btn11 = GuiCtrlCreateButton("Off", 100, 0, 40, 18, $BS_BITMAP)$btn12 = GuiCtrlCreateButton("Black", 140, 0, 40, 18, $BS_BITMAP)$btn0 = GuiCtrlCreateButton("On", 240, 0, 40, 18, $BS_BITMAP)$btn1 = GuiCtrlCreateButton("Off", 280, 0, 40, 18, $BS_BITMAP)$btn2 = GuiCtrlCreateButton("Video", 320, 0, 40, 18, $BS_BITMAP)$btn3 = GuiCtrlCreateButton("More...", 360, 0, 40, 18, $BS_BITMAP)$btnFake = GUICtrlCreateButton("fake", 500,0,10,10)
GUICtrlSetImage( $btn10, "C:\Documents and Settings\projector\My Documents\AutoIt\on1.bmp") GUICtrlSetImage($btn11, "C:\Documents and Settings\projector\My Documents\AutoIt\off1.bmp")
GUICtrlSetImage( $btn12, "C:\Documents and Settings\projector\My Documents\AutoIt\black1.bmp") GUICtrlSetImage($btn0, "C:\Documents and Settings\projector\My Documents\AutoIt\on2.bmp")
GUICtrlSetImage( $btn1, "C:\Documents and Settings\projector\My Documents\AutoIt\off1.bmp") GUICtrlSetImage($btn2, "C:\Documents and Settings\projector\My Documents\AutoIt\vid1.bmp")
GUICtrlSetImage( $btn3, "C:\Documents and Settings\projector\My Documents\AutoIt\more.bmp") GuiSetState() WinSetState("Lighting Control", "", @SW_HIDE) WinSetOnTop("Lighting Control", "", 1) GuiCtrlSetState($btnFake, $GUI_FOCUS)$state = 1

While 1
$msg = GUIGetMsg() Select Case$msg = $GUI_EVENT_CLOSE ;Destroy the GUI including the controls GUIDelete() ;Exit the script Exit Case$msg = $btn10 ProjON() Case$msg = $btn11 ProjOFF() Case$msg = $btn12 ProjBlack() Case$msg = $btn0 LightsON() Case$msg = $btn1 LightsOFF() Case$msg = $btn2 LightsDIM() Case$msg = $btn3 Run("C:\Documents and Settings\projector\My Documents\AutoIt\Lutron Control.exe") EndSelect If WinActive("EasyWorship") Then WinMove("Lighting Control", "", GetWindowX(408),GetWindowY(57)) If$state = 0 Then
WinSetState("Lighting Control", "", @SW_SHOW)
$state = 1 EndIf Else If$state = 1 Then
WinSetState("Lighting Control", "", @SW_HIDE)
\$state = 0
EndIf
EndIf
Sleep(5)
WEnd

What I'm doing is placing a small titleless window permanently ontop of another window, as if it is an existing toolbar. It has it's own button style, so I took screen shots and typed in different words, the last part is to keep focus away from the buttons. When I click one, it gets a dark black border, and a box within this one appears with a dotted line. With the focus setting onto a fake button, it removes the dotted lined box but the darker line remains. I know this sounds picky and I'm greatful that the smaller box is now gone. If there isn't a way, then I'll leave it the way it is. Thanks for all your responses so far! Here's a screen shot, the top right is the added row of buttons, for the Projectors and Lights added on top of the program EasyWorship. You can see the remaining black outline on the "On" button next to the "Projector:" label.

Edited by Sticky

##### Share on other sites

WOW Sticky, is this your application "Easy Worship"? Looks nice! Will you share the code? I would like to check it out. Thanks

## 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 account