[2024/06/06] ColorButton.ahk | Customize Gui Button Background/ Text/ Border Colors.
Posted: 01 May 2024, 13:37
This is an extended method for changing a button's background, text and border color.
![Image](https://github-production-user-asset-6210df.s3.amazonaws.com/122501303/337315160-d83b4411-c019-42d8-a44f-dacab7b858a8.gif?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240606%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240606T151413Z&X-Amz-Expires=300&X-Amz-Signature=65b31685c5930180c7db7f128f06d081d560bfe8999033b0f0aa421413b6db74&X-Amz-SignedHeaders=host&actor_id=122501303&key_id=0&repo_id=792919321)
Updates: 2024/06/06
New Features:
Learn more: https://github.com/nperovic/ColorButton.ahk/releases/tag/v1.3.0
Updates: 2024/05/06
Features
Rounded Button
![Image](https://github.com/nperovic/ColorButton.ahk/assets/122501303/b4d4f274-5605-48d7-95e4-efcde768f4af)
No Rounded Corners
![Image](https://github.com/nperovic/ColorButton.ahk/assets/122501303/63c20602-b45d-4030-93a9-0a258c70acb4)
How To Use
SetColor
Parameters
Examples
Get Code
GitHub: ColorButton.ahk
keywords: gui, gui button, win32 gui, button color, gui button color, change color, button background color, v2 gui, gdi, customdraw, roundrect, WM_NOTIFY, v2.1, alpha
![Image](https://github-production-user-asset-6210df.s3.amazonaws.com/122501303/337315160-d83b4411-c019-42d8-a44f-dacab7b858a8.gif?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240606%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240606T151413Z&X-Amz-Expires=300&X-Amz-Signature=65b31685c5930180c7db7f128f06d081d560bfe8999033b0f0aa421413b6db74&X-Amz-SignedHeaders=host&actor_id=122501303&key_id=0&repo_id=792919321)
Updates: 2024/06/06
New Features:
- Customise the button text colour.
- Customise the button border colour.
- Customise the button border display timing (always show, show on focus, never show).
- Once the button background colour is set, you can use properties to alter various settings.
- BackColor: Set/Get the Button Background Color (RGB).
- TextColor: Set/Get the Button Text Color (RGB).
- BorderColor: Button Border Color (RGB). (To set the border color, you must have used SetColor(), SetBackColor(), or BackColor to set the background color at least once beforehand.)
- RoundedCorner: Rounded Corner Preference for the Button. (To set the rounded corner preference, you must have used SetColor(), SetBackColor(), or BackColor to set the background color at least once beforehand.)
- ShowBorder: Border Preference.
- 1: Highlight when focused.
- 0: No border displayed.
- -1: Border always visible.
Learn more: https://github.com/nperovic/ColorButton.ahk/releases/tag/v1.3.0
Updates: 2024/05/06
- Update structure for 32-bit AutoHotkey v2.0.X. (No changes for the structure for v2.1-alpha.x)
- Fixed the corner issues for win 10 users.
Features
- Easily change a button's 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 also supported now.
- Learn more about the ahk v2.1-alpha: Click here
Rounded Button
No Rounded Corners
How To Use
- Download the ColorButton.ahk file.
- Include the ColorButton.ahk file in your script.
- Implement the background color by using the SetBackColor method on your button object.
SetColor
Code: Select all
GuiCtrl.SetColor(bgColor, txColor?, showBorder := 1, borderColor := 0xFFFFFF, roundedCorner?)
Parameters
bgColor
Type: Integer
Button's background color. (RGB)
Button's background color. (RGB)
txColor
Type: Integer (Optional)
Button text color (RGB). If omitted, the text colour will be automatically set to white or black depending on the background colour.
Button text color (RGB). If omitted, the text colour will be automatically set to white or black depending on the background colour.
showBorder
Type: Boolean (Optional)
Border display preference.
Border display preference.
1: Highlight when focused.
0: No border displayed.
-1: Border always visible.
borderColor
roundedCorner
Type: Integer (Optional)
Rounded corner preference for the button.
Rounded corner preference for the button.
For Windows 11: Enabled (value: 9).
For Windows 10: Disabled.
Examples
Get Code
GitHub: ColorButton.ahk
keywords: gui, gui button, win32 gui, button color, gui button color, change color, button background color, v2 gui, gdi, customdraw, roundrect, WM_NOTIFY, v2.1, alpha