Gui, Color?

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Posts: 865
Joined: 29 Sep 2013, 22:18

Gui, Color?

08 May 2020, 15:44

The help file states:
WindowColor is used as the background for the GUI window itself. ControlColor is applied to all present and future controls in the window (though some types of controls do not support a custom color). Although ControlColor is initially obeyed by ListViews and TreeViews, subsequent changes to ControlColor do not affect them. In such cases, use GuiControl +BackgroundFF9977, MyListView to explicitly change the color.

Leave either parameter blank to retain the current color. Otherwise, specify one of the 16 primary HTML color names or a 6-digit RGB color value (the 0x prefix is optional), or specify the word Default to return either to its default color. Example values: Silver, FFFFAA, 0xFFFFAA, Default.

So why am I seeing a gray background and black text in this example:

Code: Select all

col := 762e1c	; test color via an RGB color mixer

Gui, Test:New, +AlwaysOnTop -caption border
Gui, Color, %col%, white
Gui, margin, 15, 15
Gui, font, s30 bold
Gui, add, text, w300 center, This is a test
Gui, show
I found that adding 0x works for the background. Does text ignore the Gui control color option? Which controls actually use it? I think the help file could be a little bit more helpful in this case. Thanks.
Posts: 4495
Joined: 30 Sep 2013, 06:48

Re: Gui, Color?

08 May 2020, 17:42

Generally, in an expression, the 0x for a hex number is not optional like in the specific Color parameters of which you quoted the docs.

So, either use a string or a hex number for this use case:

Code: Select all

col := "762e1c"	; test color via an RGB color mixer
; or:
col := 0x762e1c
The 762e1c in col := 762e1c on the other hand, is seen as a variable name (which is empty in this case), not as a string (that was of course different in legacy/= syntax). So col will end up blank here - that's general expression behaviour.

Font/Text has its own color option (but it is no background color like in "Color: Sets the background color of the window and/or its controls.", which you quoted above): wrote:C: Color name (see color chart) or RGB value -- or specify the word Default to return to the system's default color (black on most systems). Example values: cRed, cFFFFAA, cDefault. Note: Buttons do not obey custom colors. Also, an individual control can be created with a font color other than the current one by including the C option. For example: Gui, Add, Text, cRed, My Text.
Probably it wouldn't make much sense to set all colors (of the background and the text) to the same value, at the same time.
I think standard Text elements have no own background color, but I am a command line and hotkey person... I rarely use GUIs, or custom colors :shifty: . wrote:some types of controls do not support a custom color
Sure, that is a bit vague at this point. You could make a suggestion in the dedicated subforum.
User avatar
Posts: 865
Joined: 29 Sep 2013, 22:18

Re: Gui, Color?

09 May 2020, 19:35

Thanks, gregster, you made it very clear.
Posts: 2295
Joined: 22 Dec 2013, 12:50

Re: Gui, Color?

10 May 2020, 07:22

@gregster , thankx
just a short GUI example , you can set color for : GUI ,Text ,Edit ,Font, Button, Listview ...

Code: Select all

Gui,2: -DPIScale
;Gui,2:Color,C8D0D4,Black                      ;-GUI gray    / EDIT is BLACK
Gui,2:Color,762e1c,Black                       ; GUI bordeaux/ EDIT is BLACK
Gui,2:Font,CYellow s12,Lucida Console          ; EDIT-TEXT is Yellow
Gui,2:add,Text,    x10    y10  cWhite,TEXT=    ; Text is white
Gui,2:add,Edit,    x120   y10  w660 h190    left   vE1 ,Line1`nLine2`n
Gui,2: Add, Progress, x20 y220 w180 h37 Disabled Background87CEEB vA1
Gui,2: Add, Text, xp yp wp hp BackgroundTrans 0x201 cBlack vText +Border gA1,BUTTON-1
Gui,2:Show,x1 y1 w800 h280 ,%name1%
GuiControl, Focus,E1


Return to “Ask For Help”

Who is online

Users browsing this forum: azik0244, felipe93, marqqer, Robbl and 66 guests