Autohotkey: Remove window border

六月ゝ 毕业季﹏ 提交于 2019-12-25 01:44:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!