Jump to content

Change titlebar colors of AutoIt gui


taurus905
 Share

Recommended Posts

Hello All,

Is there a simple way to change the titlebar colors?

For example, if I wanted the background to be red and the font to be white.

I've searched the forum, but was hoping for a more up-to-date method, since I couldn't get anything to work properly from years past.

Thank you, as always, for any help in pointing me in the right direction.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

Hi @taurus905,

9 hours ago, taurus905 said:

[...] but was hoping for a more up-to-date method, since I couldn't get anything to work properly from years past. [...]

can you please share your code. Which "old" method do you referring to?

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

@SOLVE-SMART Thank you for your interest in my query.

I first did a search for "titlebar color".

This seemed to be the most relevant, but it doesn't seem the OPs question was really answered.

They wanted to do the same as me.

Which is, only change the titlebar background and font colors of one AutoIt gui, without affecting other titlebars on the system.

taurus905

 

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

At least this code works for me 🧐 . It's not exactly what you want, but a starting point.

Out of a quick view regarding how to adjust the code, by the help file statements to _WinAPI_GetSysColor and _WinAPI_SetSysColors, I personal would avoid struggling with the adjustment. 💡 I would create a custom title bar (combination of labels with background color, borders etc.).

Best regards
Sven

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

As far as I understand correct, the UDF isn't working for Win10 and @funkey will not update/maintain this UDF anymore. See the conversation of your linked thread "FunSkin UDF 2022ized ?".

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

6 minutes ago, ahmet said:

I think it does work if you use the updated version by @AutoBert.

Nice @ahmet, then this could be one way to go @taurus905 😀 .

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

@ahmet Thank you for finding the FunSkin UDF and posting to my query.

@AutoBert Thank you for updating the UDF to work for Window 10 and 11.

@funkey Thank you for creating the original FunSkin project.

@SOLVE-SMART Thank you for not giving up on my question and keeping this thread alive until the solution was found.

This looks very promising.

I will have to dig deeper to customize it to fit my needs.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

After careful consideration, a theme is not what I'm looking for.

I don't want any extra files.

I simply want to change the color of one AutoIt gui titlebar and it's font.

I will keep looking for the way to do this.

Any further direction will be appreciated.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

5 hours ago, taurus905 said:

@SOLVE-SMART Thank you for not giving up on my question and keeping this thread alive until the solution was found.

You're welcome 😀 .

2 hours ago, taurus905 said:

After careful consideration, a theme is not what I'm looking for.

I don't want any extra files.

That's why I think a custom title bar is, at least for me, the way to go. Of course it would be fine, to use a completed UDF or functionality, but if your requirement is only to adjust the title bar and the given solution don't fit your needs, maybe do it on your own 🤔 .

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

You can use approach that is used in the FunSkin to change color of title bar. Addapting it to your needs might take some time, but it should not be difficult. Look for a line where title bar is being colored now and try to chanhe that with a solid color for any theme for start. Once that is done you can move to next step - removing dependency on external files. I think you should be looking for something like WinAPIFill..., but it is only a guess.

Link to comment
Share on other sites

There seems to be many way to achieve something like you're looking for, thanks to this nice and experienced community 👍 .
Nevertheless I want to show you @taurus905 a quick example of a custom title bar which I created out of GUI snippets that I used in other projects before.

💡 Please keep in mind, I usually would modularize the code into separate files (depending on the duties), but in this case I just did it in a single script file.

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#AutoIt3Wrapper_UseUpx=n
#Au3Stripper_Parameters=/sf /sv /mo /rm /rsln

#include-once
#include <GUIConstants.au3>
#include <Misc.au3>

Global $mGui[], $mTitleBar[]
Global $mClosingCrossIcon[], $mMinimizeIcon[]

Global $mTitleBarColor[]
$mTitleBarColor.background    = 0xD9534F
$mTitleBarColor.font          = 0xFBEDED
$mTitleBarColor.faviconIcon   = $GUI_BKCOLOR_TRANSPARENT
$mTitleBarColor.hoverMinimize = 0xE5E5E5
$mTitleBarColor.hoverClose    = 0xE81123

_Actions()

Func _Actions()
    _CreateGui()
    _CreateTitleBar()
    _AddTitleBarButtons()
    _ShowGui()
    _GuiEventListener()
EndFunc

Func _CreateGui()
    $mGui.Width  = 600
    $mGui.Height = 350
    $mGui.Style  = $WS_POPUP
    $mGui.Handle = GUICreate('', $mGui.Width, $mGui.Height, Default, Default, $mGui.Style)
EndFunc

Func _CreateTitleBar()
    ; background
    $mTitleBar.X            = 0
    $mTitleBar.Y            = 0
    $mTitleBar.W            = ($mGui.Width - 137)
    $mTitleBar.H            = 26
    $mTitleBar.ButtonWidth  = 25
    $mTitleBar.ButtonHeight = $mTitleBar.ButtonWidth

    $mTitleBar.cId = GUICtrlCreateLabel('', $mTitleBar.X, $mTitleBar.Y, $mTitleBar.W, $mTitleBar.H)
    GUICtrlSetBkColor($mTitleBar.cId, $mTitleBarColor.background)
    GUICtrlSetStyle($mTitleBar.cId, -1, $GUI_WS_EX_PARENTDRAG)

    ; favicon icon
    GUICtrlCreateLabel('🎲', 4, 5.5) ; I used the cube icon as example which can be pasted in by pressing [WIN] + [.]
    GUICtrlSetBkColor(-1, $mTitleBarColor.faviconIcon)
    GUICtrlSetFont(-1, 11)

    ; title
    GUICtrlCreateLabel('GUI with custom title bar', 24, 5.5, ($mGui.Width / 2))
    GUICtrlSetColor(-1, $mTitleBarColor.font)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 9)
EndFunc

Func _AddTitleBarButtons()
    _AddClosingCrossIcon()
    _AddMaximizeIcon()
    _AddMinimizeIcon()
EndFunc

Func _AddClosingCrossIcon()
    ; background
    $mClosingCrossIcon.X = ($mGui.Width - 45)
    $mClosingCrossIcon.Y = 0
    $mClosingCrossIcon.W = $mTitleBar.ButtonWidth + 20
    $mClosingCrossIcon.H = $mTitleBar.ButtonHeight + 1

    $mClosingCrossIcon.cId = GUICtrlCreateLabel('', $mClosingCrossIcon.X, $mClosingCrossIcon.Y, $mClosingCrossIcon.W, $mClosingCrossIcon.H)
    GUICtrlSetBkColor($mClosingCrossIcon.cId, $mTitleBarColor.background)

    ; icon
    GUICtrlCreateLabel(ChrW(0xCD), ($mGui.Width - 31), 5.5, $mTitleBar.ButtonWidth, $mTitleBar.ButtonHeight)
    GUICtrlSetFont(-1, 14, 100, Default, 'Wingdings 2')
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
EndFunc

Func _AddMaximizeIcon()
    ; background
    GUICtrlCreateLabel('', ($mGui.Width - 92), 0, $mTitleBar.ButtonWidth + 22, $mTitleBar.ButtonHeight + 1)
    GUICtrlSetBkColor(-1, $mTitleBarColor.background)

    ; icon
    GUICtrlCreateLabel(ChrW(0xA3), ($mGui.Width - 75), 6.5, $mTitleBar.ButtonWidth, $mTitleBar.ButtonHeight)
    GUICtrlSetFont(-1, 11, 100, Default, 'Wingdings 2')
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xCCCCCC)
EndFunc

Func _AddMinimizeIcon()
    ; background
    $mMinimizeIcon.X = ($mGui.Width - 137)
    $mMinimizeIcon.Y = 0
    $mMinimizeIcon.W = $mTitleBar.ButtonWidth + 20
    $mMinimizeIcon.H = $mTitleBar.ButtonHeight + 1

    $mMinimizeIcon.cId = GUICtrlCreateLabel('', $mMinimizeIcon.X, $mMinimizeIcon.Y, $mMinimizeIcon.W, $mMinimizeIcon.H)
    GUICtrlSetBkColor($mMinimizeIcon.cId, $mTitleBarColor.background)

    ; icon
    GUICtrlCreateLabel(ChrW(0x2015), ($mGui.Width - 119), 6.5, $mTitleBar.ButtonWidth, $mTitleBar.ButtonHeight)
    GUICtrlSetFont(-1, 8, 100, Default, 'Segoe UI')
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
EndFunc

Func _ShowGui()
    GUISetState(@SW_SHOW, $mGui.Handle)
EndFunc

Func _GuiEventListener()
    AdlibRegister('_HoverActions', 100)
    Local Const $iGuiEventClose = -3

    While True
        Switch GUIGetMsg()
            Case $iGuiEventClose, $mClosingCrossIcon.cId
                ExitLoop
            Case $mMinimizeIcon.cId
                GUISetState(@SW_MINIMIZE, $mGui.Handle)
        EndSwitch
    WEnd

    _GuiDisposeAndExit()
EndFunc

Func _GuiDisposeAndExit()
    AdlibUnRegister('_HoverActions')
    GUIDelete($mGui.Handle)
    Exit
EndFunc

Func _HoverActions()
    Local $aMouseData = MouseGetPos()
    Local $aGuiData   = WinGetPos($mGui.Handle)

    If Not _HoverTitleBar($aMouseData, $aGuiData) Then
        _ResetHoverColor()
        Return
    EndIf

    Select
        Case _HoverMinimizeIcon($aMouseData, $aGuiData)
            GUICtrlSetBkColor($mMinimizeIcon.cId, $mTitleBarColor.hoverMinimize)
            GUICtrlSetBkColor($mClosingCrossIcon.cId, $mTitleBarColor.background)

        Case _HoverClosingCrossIcon($aMouseData, $aGuiData)
            GUICtrlSetBkColor($mClosingCrossIcon.cId, $mTitleBarColor.hoverClose)
            GUICtrlSetBkColor($mMinimizeIcon.cId, $mTitleBarColor.background)

        Case Else
            _ResetHoverColor()
    EndSelect
EndFunc

Func _ResetHoverColor()
    GUICtrlSetBkColor($mClosingCrossIcon.cId, $mTitleBarColor.background)
    GUICtrlSetBkColor($mMinimizeIcon.cId, $mTitleBarColor.background)
EndFunc

Func _HoverTitleBar($aMouseData, $aGuiData)
    Return _IsMouseOnControl( _
        $aMouseData[0] - $aGuiData[0], _
        $aMouseData[1] - $aGuiData[1], _
        $mTitleBar.X, $mTitleBar.Y, $mGui.Width, $mTitleBar.H)
EndFunc

Func _HoverMinimizeIcon($aMouseData, $aGuiData)
    Return _IsMouseOnControl( _
        $aMouseData[0] - $aGuiData[0], _
        $aMouseData[1] - $aGuiData[1], _
        $mMinimizeIcon.X, $mMinimizeIcon.Y, $mMinimizeIcon.W, $mMinimizeIcon.H)
EndFunc

Func _HoverClosingCrossIcon($aMouseData, $aGuiData)
    Return _IsMouseOnControl( _
        $aMouseData[0] - $aGuiData[0], _
        $aMouseData[1] - $aGuiData[1], _
        $mClosingCrossIcon.X, $mClosingCrossIcon.Y, $mClosingCrossIcon.W, $mClosingCrossIcon.H)
EndFunc

Func _IsMouseOnControl($iXMouse, $iYMouse, $iXControl, $iYControl, $iWidthControl, $iHeightControl)
    If $iXMouse >= $iXControl And _
       $iYMouse >= $iYControl And _
       $iXMouse <= $iXControl + $iWidthControl  And _
       $iYMouse <= $iYControl + $iHeightControl Then
       Return True
    Else
        Return False
    EndIf
EndFunc

It was more complex than I thought, but as a proof of concept I enjoyed it 😅 .
Please notice that you can minimize or close the GUI like you would expect it. Also the GUI is draggable by the title bar.

👓 Open the spoiler box to see the example:

Spoiler

default-gui.gif

custom-gui-titlebar.gif

Best regards
Sven

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

1 hour ago, SOLVE-SMART said:

There seems to be many way to achieve something like you're looking for, thanks to this nice and experienced community 👍 .

@SOLVE-SMART Your above statement is very correct and your example script is great.

I like your use of small functions which make the code easier to follow.

Thank you for taking the time to address my problem, as I was exploring other possible solutions.

You live-up to your name, "Solve-Smart".

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

9 hours ago, taurus905 said:

I like your use of small functions which make the code easier to follow:

Thanks @taurus905, I appreciate that you noticed this 😀 . For me it's almost all about readability and quick understanding of code even if I have to write more code (more functions). Anyway, thanks 🤝 .

9 hours ago, taurus905 said:

You live-up to your name, "Solve-Smart".

😊 At least I try so and do my best.

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...