An extended method for changing a button's background color.
- Easily change a button's background color.
- Automatically set the text colour to white or black depends on the background colour.
- Compatible with AutoHotkey v2.1-alpha.9 or later. (Update: v2.0 is now supported too.)
- Learn more about the ahk v2.1-alpha: Click here
- Download the ColorButton.ahk file.
- Include the ColorButton.ahk file in your script.
- Implement the background color by using the
SetBackColor
method.
/**
* @param {Gui.Button} myBtn omitted.
* @param {integer} btnBgColor Button's background color.
* @param {integer} [colorBehindBtn] The color of the button's surrounding area. If omitted, if will be the same as `myGui.BackColor`.
* @param {integer} [roundedCorner] Specifies the rounded corner preference for the button. If omitted, :
* > For Windows 11: Enabled. (value: 9)
* > For Windows 10: Disabled.
*/
myBtn.SetBackColor(btnBgColor, colorBehindBtn?, roundedCorner?)
#requires AutoHotkey v2
#include <ColorButton>
myGui := Gui()
myGui.SetFont("cWhite s24", "Segoe UI")
myGui.BackColor := 0x2c2c2c
btn := myGui.AddButton(, "SUPREME")
btn.SetBackColor(0xaa2031)
myGui.Show("w300 h300")
btn.SetBackColor(0xaa2031,, 9)
myGui.Show("w300 h300")
This project is licensed under the MIT License - see the LICENSE.md file for details.
本程式庫為內建類別 Gui.Button
擴充了一個更改按鈕背景顏色的方法。
- 輕鬆更改按鈕的背景顏色。
- 自動根據背景色彩的深淺設定文字色彩 (深色背景+白色文字或淺色背景+黑色文字)。
- 支援 AutoHotkey v2.0 或更高版本。
- 想知道更多關於 ahk v2.1-alpha 的資訊,請按這裡。
- 下載 ColorButton.ahk 文件。
- 在您的程式碼中加入 ColorButton.ahk 。
- 使用
SetBackColor
方法變更按鈕背景色彩。
/**
* @param {Gui.Button} myBtn omitted.
* @param {integer} btnBgColor Button's background color.
* @param {integer} [colorBehindBtn] The color of the button's surrounding area. If omitted, if will be the same as `myGui.BackColor`.
* @param {integer} [roundedCorner] Specifies the rounded corner preference for the button. If omitted, :
* > For Windows 11: Enabled. (value: 9)
* > For Windows 10: Disabled.
*/
myBtn.SetBackColor(btnBgColor, colorBehindBtn?, roundedCorner?)
#requires AutoHotkey v2
#include <ColorButton>
myGui := Gui()
myGui.SetFont("cWhite s24", "Segoe UI")
myGui.BackColor := 0x2c2c2c
btn := myGui.AddButton(, "SUPREME")
btn.SetBackColor(0xaa2031)
myGui.Show("w300 h300")
btn.SetBackColor(0xaa2031,, 9)
myGui.Show("w300 h300")
本項目根據 MIT 許可證進行許可 - 請參閱 LICENSE.md 文件以獲取詳細資訊。
Proširena metoda za promenu boje pozadine dugmeta.
- Lako promenite boju pozadine dugmeta.
- Kompatibilno sa AutoHotkey v2.0 ili novijim verzijama.
- Saznajte više o ahk v2.1-alpha: Kliknite ovde
- Preuzmite ColorButton.ahk datoteku.
- Uključite ColorButton.ahk datoteku u vaš skript.
- Implementirajte boju pozadine koristeći
SetBackColor
metodu.
#requires AutoHotkey v2
#include <ColorButton>
myGui := Gui()
myGui.SetFont("cWhite s24", "Segoe UI")
myGui.BackColor := 0x2c2c2c
btn := myGui.AddButton(, "SUPREME")
btn.SetBackColor(0xaa2031)
myGui.Show("w300 h300")
Ovaj projekat je licenciran pod MIT Licencom - za detalje pogledajte LICENSE.md datoteku.