Buttons turn blue after clicking

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
talormanda
Posts: 11
Joined: 03 Oct 2014, 15:17

Buttons turn blue after clicking

03 Oct 2014, 15:25

I have a GUI which has 2 GUIs inside it. When the buttons are pressed, it leaves them with a blue glow around it and I cannot figure out how to make it not do that

Image Image

I don't want it to turn blue after clicking because it stays like that and it looks weird. If I only have 1 GUI, the effect is gone.

Code: Select all

#SingleInstance Force
#Persistent
SendMode Input

Gui 1:+LastFound

Gui 2:Add, Text,, Stuff and crap
Gui 2:Add, Button, gGui1, Gui1 button
Gui 2:+Owner1 +Parent1 -Caption

Gui 3:Add, Text,, Other stuff and stuffs
Gui 3:Add, Button, gGui2, Gui2 button
Gui 3:+Owner1 +Parent1 -Caption

Menu, View, Add, Simple View, sview
Menu, View, Add, Advanced View, aview
Menu, MainMenu, Add, View, :View

Gui, Menu, MainMenu
Gui, 1:Show,w200 h100,Menu
Gui, 2:Show,x0 y0
return

GuiClose:
ExitApp

Gui1:
msgbox Gui1
return

Gui2:
msgbox Gui2
return

sview:
Gui 3:hide
Gui 2:show,x0 y0
return

aview:
Gui 2:hide
Gui 3:show,x0 y0
return
lexikos
Posts: 9599
Joined: 30 Sep 2013, 04:07
Contact:

Re: Buttons turn blue after clicking

03 Oct 2014, 19:26

The appearance of the button is controlled by the system theme/visual style, unless you add -Theme to its options.

I can't imagine why you'd think it looks weird. Every other button on your system probably does the same thing (when it has the focus). If you don't like the look, maybe you should use a different visual style rather than making your script inconsistent with every other program (well, most).

Here's how it looks on my system:
Attachments
Untitled.png
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Buttons turn blue after clicking

03 Oct 2014, 19:42

Hi talormanda ,
You won't be able to, it is a windows thing. Which is also why you can't change color
from MS's ugly default off white. There are some scripts on this site to change color but all/most use
tic's Gdip lib. IMHO to much code for a few keys.
I would do this, change these 2 lines from :
Gui 2:Add, Button, gGui1, Gui1 button
Gui 3:Add, Button, gGui1, Gui1 button
To:
Gui 2:Add, Picture, gGui1, Z:\Images\button.png
Gui 3:Add, Picture, gGui1, Z:\Images\button.png

The Z:\Images\button.png is the image you want and its path.

Here are 3 sites where you can make basic buttons:
http://buttonoptimizer.com/
http://dabuttonfactory.com/
http://www.imagefu.com/create/button

Happy programing, hunter

I see lexikos beat me to your answer.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Buttons turn blue after clicking

03 Oct 2014, 20:17

If you want to keep the theme and remove the blue highlight state try this [tested in Win7 only!!]:

Code: Select all

OnMessage( 0x202, "RemoveState" )
Gui, Add, Button, vBtn, Press
Gui, Show, w200
Return

GuiClose:
ExitApp

RemoveState()
{
    GuiControl, -0x1, Btn
}
found this by monitoring the style codes per button control state.
go figure it was 1 digit, lol crazy..
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Buttons turn blue after clicking

03 Oct 2014, 22:09

Hi TLM, that works on my win7 and win8 sys., until you add a gsub to the button or click on the menu window.
If you could try it ; maybe just a msgbox, because it would be nice to know if it is just the users win setups.
Myself and others did alot of looking into this a couple of years ago with no results.
Funny thing these GUI's. Have a goodnight, hunter
talormanda
Posts: 11
Joined: 03 Oct 2014, 15:17

Re: Buttons turn blue after clicking

03 Oct 2014, 22:42

TLM wrote:If you want to keep the theme and remove the blue highlight state try this [tested in Win7 only!!]:

Code: Select all

OnMessage( 0x202, "RemoveState" )
Gui, Add, Button, vBtn, Press
Gui, Show, w200
Return

GuiClose:
ExitApp

RemoveState()
{
    GuiControl, -0x1, Btn
}
found this by monitoring the style codes per button control state.
go figure it was 1 digit, lol crazy..
Yeah, like I stated, when I only have 1 GUI only with buttons on it, theres no blue highlight that sticks. With this one, if I make 10 buttons for example and start clicking on them, they all get that blue highlight and it doesn't go away. I figured it was a bug or something since with 1 GUI (no parent and child gui's) it's fine and that doesn't happen. Just was wondering if something in my code caused that, but I couldn't figure it out. Even when the button isn't in focus, it does it.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Buttons turn blue after clicking

03 Oct 2014, 23:06

hunter99 wrote:Hi TLM, that works on my win7 and win8 sys., until you add a gsub to the button or click on the menu window.
When all else fails its then time to ratchet through several Windows Messages to simultaneously apply the style change.

Code: Select all

For i, wm_ in wm_arr := [ "0x202", "0x318", "0x20", "0x135" ]
{
    OnMessage( wm_, "RemoveState" )
}

Gui, Add, Button, vBtn gSub, Press
Gui, Show, w200
Return

GuiClose:
ExitApp

Sub:
    msgbox some sub routine.
return

RemoveState()
{
    GuiControl, -0x1, Btn
}
0x135 [ WM_CTLDOLORDLG ] might be enough but it seems to be quite effective in combination with 0x202 [ WM_LBUTTONUP ]. I obviously added others jic..

Please test this thoroughly.
talormanda
Posts: 11
Joined: 03 Oct 2014, 15:17

Re: Buttons turn blue after clicking

04 Oct 2014, 00:27

Here's a thought, the buttons basically turning into a "pressed down" or "selected" state and doesn't come out of that state after being pressed once. Can we just add a small something to de-select it after it's clicked and runs whatever it's linked to?
just me
Posts: 9482
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Buttons turn blue after clicking

04 Oct 2014, 04:17

Code: Select all

#NoEnv
#SingleInstance Force
#Persistent
SendMode Input

Gui 1:+LastFound

Gui 2:Add, Text,, Stuff and crap
Gui 2:Add, Button, gGui1, Gui1 button
Gui 2:+Owner1 +Parent1 -Caption

Gui 3:Add, Text,, Other stuff and stuffs
Gui 3:Add, Button, gGui2, Gui2 button
Gui 3:+Owner1 +Parent1 -Caption

Menu, View, Add, Simple View, sview
Menu, View, Add, Advanced View, aview
Menu, MainMenu, Add, View, :View

Gui, Menu, MainMenu
Gui, 1:Show,w200 h100,Menu
Gui, 2:Show,x0 y0
return

GuiClose:
ExitApp

Gui1:
msgbox Gui1
GuiControl, -Default, %A_GuiControl% ; <<<<<<<<<<<<<<<<<<<<<<<
return

Gui2:
msgbox Gui2
GuiControl, -Default, %A_GuiControl% ; <<<<<<<<<<<<<<<<<<<<<<<
return

sview:
Gui 3:hide
Gui 2:show,x0 y0
return

aview:
Gui 2:hide
Gui 3:show,x0 y0
return
?
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Buttons turn blue after clicking

04 Oct 2014, 07:38

TLM, that does the job nicely. You really dig into those style codes.

just me, you nailed it, this should make the op happy.
Had looked at GuiControl before and never saw the -default option, or if so it didn't register.
Too many senior moments of late. Thank you both for the learning experiance.
hunter
talormanda
Posts: 11
Joined: 03 Oct 2014, 15:17

Re: Buttons turn blue after clicking

04 Oct 2014, 10:31

just me wrote:

Code: Select all

#NoEnv
#SingleInstance Force
#Persistent
SendMode Input

Gui 1:+LastFound

Gui 2:Add, Text,, Stuff and crap
Gui 2:Add, Button, gGui1, Gui1 button
Gui 2:+Owner1 +Parent1 -Caption

Gui 3:Add, Text,, Other stuff and stuffs
Gui 3:Add, Button, gGui2, Gui2 button
Gui 3:+Owner1 +Parent1 -Caption

Menu, View, Add, Simple View, sview
Menu, View, Add, Advanced View, aview
Menu, MainMenu, Add, View, :View

Gui, Menu, MainMenu
Gui, 1:Show,w200 h100,Menu
Gui, 2:Show,x0 y0
return

GuiClose:
ExitApp

Gui1:
msgbox Gui1
GuiControl, -Default, %A_GuiControl% ; <<<<<<<<<<<<<<<<<<<<<<<
return

Gui2:
msgbox Gui2
GuiControl, -Default, %A_GuiControl% ; <<<<<<<<<<<<<<<<<<<<<<<
return

sview:
Gui 3:hide
Gui 2:show,x0 y0
return

aview:
Gui 2:hide
Gui 3:show,x0 y0
return
?
Getting there for sure. I'll continue to play around with this. If I click the button it certainly de-selects it, but if I click anywhere on the window the activate that window, the button is on, it selects again.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 417 guests