问题
I would like to display just some text with a background. Despite my attempts, there is a lot of empty space around the text.
Gui, +AlwaysOnTop -Border -SysMenu -Caption
Gui, Add, Text, , Some text
Gui, Show, AutoSize
WinSet, Style, -0xC00000, A
WinSet, Style, -0x40000, A
WinSet, ExStyle, -0x00000200, A
If, instead of AutoSize
, I manually set the size, the text is cut.
回答1:
If you add a border to the text, i.e.,
Gui Add, Text, Border, Some text
you'll see it is indeed the window itself with the extra space and not the text control. By default, if no margin is given to a GUI before a control is added it chooses one that is proportional to the font. So, just set the margin to zero before you add the text control:
Gui Margin, 0, 0
Gui Add, Text,, Some text
回答2:
This is close to what you are looking for but not the same. This code will change the BG Color to transparent leaving only the text. Figured it would be worth showing off here for future users.
This example is using the CustomColor as a color to turn into the transparent field.
CustomColor = EEAA99
Gui, +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Font, s32
Gui, Add, Text, , Some text
Gui, Color, %CustomColor%
WinSet, TransColor, %CustomColor% 1000
Gui, Show, AutoSize,NoActivate
来源:https://stackoverflow.com/questions/49364373/autohotkey-remove-window-border