Jump to content

[solved] Help with fake GUI coloring


argumentum
 Share

Recommended Posts

I'm putting together a "High Contrast" theme editor ( here ) and it'd be nice to have a preview.
Now, the colors for the inactive window's close/restore/minimize, is a type of alpha of the color:
image.png.7cdf87f72c436d413d4e3d76c4ac8635.png
and I have no clue on how to get that done, hence my cry request for help.

Here is a sampler code to what I'm doing:

#cs ----------------------------------------------------------------------------
2019.11.14
still brainstorming.  No necesarely the final appreoach to the desired outcome.
#ce ----------------------------------------------------------------------------
#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <File.au3>
#include <Array.au3>
#include <Debug.au3>

#include <ColorConstants.au3>

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


Global $aFD, $iCursorInfo = 0, $Form, $g_WinSysColors = WindowsColorConstants()
Global Enum $e_Desktop = 1, $eI_Window_Highlight, $eI_Window_Border, $eI_Window_Canvas, $eI_Window_CloseHighlight, $eI_Window_Title, $eI_Window_Icon, _
        $eI_Window_Close, $eI_Window_RestoreHighlight, $eI_Window_Restore, $eI_Window_MinimizeHighlight, $eI_Window_Minimize, _
        $eA_Window_Highlight, $eA_Window_Border, $eA_Window_Canvas, $eA_Window_CloseHighlight, $eA_Window_Title, $eA_Window_Icon, _
        $eA_Window_Close, $eA_Window_RestoreHighlight, $eA_Window_Restore, $eA_Window_MinimizeHighlight, $eA_Window_Minimize


main()
Func main()

    Opt("GUIOnEventMode", 1)
    $Form = GUICreate(Chr(160) & StringTrimRight(@ScriptName, 4) & Chr(160), 1200, 31 * 21, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnForm_Close")
    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "OnForm_MouseMove")

    For $n = 1 To 30
        $g_WinSysColors[$n][10] = GUICtrlCreateLabel(StringReplace($g_WinSysColors[$n][0], "Color_", "") & "  [ " & StringRight("00" & $g_WinSysColors[$n][1], 2) & " ]", 3, 20 * $n, 200, 19, BitOR($SS_RIGHT, $SS_CENTERIMAGE))
        Switch $g_WinSysColors[$n][1]
            Case 1
                GUICtrlSetTip(-1, "$" & $g_WinSysColors[$n][0] & @LF & "$" & $g_WinSysColors[31][0])
            Case 15
                GUICtrlSetTip(-1, "$" & $g_WinSysColors[$n][0] & @LF & "$" & $g_WinSysColors[32][0])
            Case 16
                GUICtrlSetTip(-1, "$" & $g_WinSysColors[$n][0] & @LF & "$" & $g_WinSysColors[33][0])
            Case 20
                GUICtrlSetTip(-1, "$" & $g_WinSysColors[$n][0] & @LF & "$" & $g_WinSysColors[34][0] & @LF & "$" & $g_WinSysColors[35][0] & @LF & "$" & $g_WinSysColors[36][0])
            Case Else
                GUICtrlSetTip(-1, "$" & $g_WinSysColors[$n][0])
        EndSwitch
        $g_WinSysColors[$n][11] = GUICtrlCreateLabel("", 209, 20 * $n, 30, 19, BitOR($SS_RIGHT, $SS_CENTERIMAGE))
        $g_WinSysColors[$n][5] = _WinAPI_SwitchColor(_WinAPI_GetSysColor($g_WinSysColors[$n][1]))
        GUICtrlSetBkColor($g_WinSysColors[$n][11], $g_WinSysColors[$n][5])
        $g_WinSysColors[$n][12] = GUICtrlCreateLabel($g_WinSysColors[$n][2], 245, 20 * $n, 130, 19, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE)
    Next

    GUISetState(@SW_SHOW, $Form)
    FakeDesktop_Build()

    Local $i_CursorInfo = 0

    $aFD[$eA_Window_Minimize][1] = "$eA_Window_Minimize"
    _DebugArrayDisplay($aFD)

    While 1
        If $iCursorInfo Then
            $i_CursorInfo = $iCursorInfo
            $iCursorInfo = 0
            OnCursorChange($i_CursorInfo)
        EndIf
        Sleep(10)
    WEnd
EndFunc   ;==>main

Func OnCursorChange($i_CursorInfo)
    Local Static $iMouseOver_CloseMin = 0
    Switch $i_CursorInfo
        Case $aFD[$eI_Window_Close][0]
            OnCursorChange_HideBttns_CloseMin()
            $iMouseOver_CloseMin = $aFD[$eI_Window_CloseHighlight][0]
            GUICtrlSetState($iMouseOver_CloseMin, $GUI_SHOW)
        Case $aFD[$eI_Window_Restore][0]
            OnCursorChange_HideBttns_CloseMin()
            $iMouseOver_CloseMin = $aFD[$eI_Window_RestoreHighlight][0]
            GUICtrlSetState($iMouseOver_CloseMin, $GUI_SHOW)
        Case $aFD[$eI_Window_Minimize][0]
            OnCursorChange_HideBttns_CloseMin()
            $iMouseOver_CloseMin = $aFD[$eI_Window_MinimizeHighlight][0]
            GUICtrlSetState($iMouseOver_CloseMin, $GUI_SHOW)
        Case $aFD[$eA_Window_Close][0]
            OnCursorChange_HideBttns_CloseMin()
            $iMouseOver_CloseMin = $aFD[$eA_Window_CloseHighlight][0]
            GUICtrlSetState($iMouseOver_CloseMin, $GUI_SHOW)
        Case $aFD[$eA_Window_Restore][0]
            OnCursorChange_HideBttns_CloseMin()
            $iMouseOver_CloseMin = $aFD[$eA_Window_RestoreHighlight][0]
            GUICtrlSetState($iMouseOver_CloseMin, $GUI_SHOW)
        Case $aFD[$eA_Window_Minimize][0]
            OnCursorChange_HideBttns_CloseMin()
            $iMouseOver_CloseMin = $aFD[$eA_Window_MinimizeHighlight][0]
            GUICtrlSetState($iMouseOver_CloseMin, $GUI_SHOW)
        Case Else
            If $iMouseOver_CloseMin Then
                OnCursorChange_HideBttns_CloseMin()
                $iMouseOver_CloseMin = 0
            EndIf
    EndSwitch


EndFunc   ;==>OnCursorChange

Func OnCursorChange_HideBttns_CloseMin()
    Local Static $a[7] = [6, $aFD[$eI_Window_MinimizeHighlight][0], $aFD[$eA_Window_MinimizeHighlight][0], $aFD[$eI_Window_CloseHighlight][0], $aFD[$eA_Window_CloseHighlight][0], $aFD[$eI_Window_RestoreHighlight][0], $aFD[$eA_Window_RestoreHighlight][0]]
    For $n = 1 To 6
        GUICtrlSetState($a[$n], $GUI_HIDE)
    Next
EndFunc   ;==>OnCursorChange_HideBttns_CloseMin

Func OnForm_MouseMove()
    Local Static $last
    Local $aCursorInfo = GUIGetCursorInfo($Form)
    If Not IsArray($aCursorInfo) Then Return
    If $last = $aCursorInfo[4] Then Return
    $last = $aCursorInfo[4]
    $iCursorInfo = $last
EndFunc   ;==>OnForm_MouseMove

Func FakeDesktop_Build()
    Local $iLeft = 390, $iTop = 20, $iWidth = 800, $iHight = 600
    Dim $aFD[100][10]
    GUICtrlCreateGroup("", $iLeft, $iTop, $iWidth, $iHight)
    $aFD[$e_Desktop][0] = GUICtrlCreateLabel("", $iLeft + 2, $iTop + 8, $iWidth - 4, $iHight - 10)
    GUICtrlSetStyle(-1, $SS_LEFT)
    GUICtrlSetBkColor($aFD[$e_Desktop][0], $g_WinSysColors[2][5])
    $aFD[0][0] = $e_Desktop
    FakeDesktop_Build_Window($aFD, $iLeft + 20, $iTop + 30, $iWidth - 80, $iHight - 100)
    FakeDesktop_Build_Window($aFD, $iLeft + 30, $iTop + 65, $iWidth - 50, $iHight - 100)
    GUICtrlSetData($aFD[$eI_Window_Title][0], "       Inactive Window")
    GUICtrlSetData($aFD[$eA_Window_Title][0], "       Active Window")
    FakeDesktop_Build_Controls($aFD, $iLeft + 40, $iTop + 98, $iWidth - 70, $iHight - 145)
    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
    FakeDesktop_Build_ColoringControls($aFD)
EndFunc   ;==>FakeDesktop_Build

Func FakeDesktop_Build_Window(ByRef $aFD, $iLeft, $iTop, $iWidth, $iHight)
    Local Enum $eI_Window_Highlight = $aFD[0][0] + 1, $eI_Window_Border, $eI_Window_Canvas, $eI_Window_CloseHighlight, $eI_Window_Title, $eI_Window_Icon, _
            $eI_Window_Close, $eI_Window_RestoreHighlight, $eI_Window_Restore, $eI_Window_MinimizeHighlight, $eI_Window_Minimize

    $aFD[$eI_Window_Highlight][0] = GUICtrlCreateLabel("", $iLeft, $iTop, $iWidth, $iHight) ; $eI_Window Highlight
    GUICtrlSetStyle(-1, $SS_LEFT)
    GUICtrlSetBkColor(-1, 0x00FFFF)
    $aFD[$eI_Window_Border][0] = GUICtrlCreateLabel("", $iLeft + 1, $iTop + 1, $iWidth - 2, $iHight - 2) ; window border
    GUICtrlSetStyle(-1, $SS_LEFT)
    GUICtrlSetBkColor(-1, 0x006600)
    $aFD[$eI_Window_Title][0] = GUICtrlCreateLabel("Title", $iLeft + 3, $iTop + 7, 400, 21) ; window title
    GUICtrlSetBkColor(-1, 0x006600)
    GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI")

    $aFD[$eI_Window_Canvas][0] = GUICtrlCreateLabel("", $iLeft + 8, $iTop + 30, $iWidth - 16, $iHight - 38) ; window
    GUICtrlSetStyle(-1, $SS_LEFT)
    GUICtrlSetState(-1, $gui_disable)
    GUICtrlSetBkColor(-1, 0xFF6600)

    $aFD[$eI_Window_RestoreHighlight][0] = GUICtrlCreateLabel("", $iLeft + $iWidth - 57 - 49, $iTop + 1, 50, 29) ; highlight
    GUICtrlSetBkColor(-1, 0x00FF66)
    GUICtrlSetState($aFD[$eI_Window_RestoreHighlight][0], $GUI_HIDE)
    $aFD[$eI_Window_Restore][0] = GUICtrlCreateLabel("p", $iLeft + $iWidth - 56 - 49, $iTop + 2, 48, 27, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ; restore
    GUICtrlSetFont(-1, 10, 800, 0, "Wingdings")
    GUICtrlSetBkColor(-1, 0xFF0000)

    $aFD[$eI_Window_CloseHighlight][0] = GUICtrlCreateLabel("", $iLeft + $iWidth - 57, $iTop + 1, 50, 29) ; highlight
    GUICtrlSetBkColor(-1, 0x00FF66)
    GUICtrlSetState($aFD[$eI_Window_CloseHighlight][0], $GUI_HIDE)
    $aFD[$eI_Window_Close][0] = GUICtrlCreateLabel("X", $iLeft + $iWidth - 56, $iTop + 2, 48, 27, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ; close
    GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
    GUICtrlSetBkColor(-1, 0xFF0000)

    $aFD[$eI_Window_MinimizeHighlight][0] = GUICtrlCreateLabel("", $iLeft + $iWidth - 57 - 49 - 49, $iTop + 1, 50, 29) ; highlight
    GUICtrlSetBkColor(-1, 0x00FF66)
    GUICtrlSetState($aFD[$eI_Window_MinimizeHighlight][0], $GUI_HIDE)
    $aFD[$eI_Window_Minimize][0] = GUICtrlCreateLabel("_", $iLeft + $iWidth - 56 - 49 - 49, $iTop + 2, 48, 27, $SS_CENTER) ;, BitOR($SS_CENTER,$SS_CENTERIMAGE)) ; minimize
    GUICtrlSetFont(-1, 12, 800, 0, "Terminal")
    GUICtrlSetBkColor(-1, 0xFF0000)

    $aFD[$eI_Window_Icon][0] = GUICtrlCreateIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1) & "\Aut2Exe\Icons\AutoIt_Old1.ico", -1, $iLeft + 8, $iTop + 8, 16, 16, $SS_ICON) ; window icon
;~  $aFD[$eI_Window_Icon][0] = GUICtrlCreateIcon(@AutoItExe, -1, $iLeft + 8, $iTop + 8, 16, 16, $SS_ICON); window icon need to be square in shape  =(

    $aFD[0][0] = $eI_Window_Minimize ; ...to know where is left off
EndFunc   ;==>FakeDesktop_Build_Window

Func FakeDesktop_Build_Controls(ByRef $aFD, $iLeft, $iTop, $iWidth, $iHight)
    #forceref $aFD,$iLeft, $iTop, $iWidth, $iHight
    ; ...have to continue this.
    ; here is where the controls are loaded and added to "ByRef $aFD"
    GUICtrlCreateButton("Button", $iLeft, $iTop, 75, 25)
    GUICtrlCreateLabel("Label", $iLeft + 100, $iTop, 75, 21, BitOR($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlCreateCheckbox("Checkbox", $iLeft + 200, $iTop, 75, 21)
    GUICtrlCreateInput("Input", $iLeft + 300, $iTop, 75, 21)

EndFunc   ;==>FakeDesktop_Build_Controls

Func FakeDesktop_Build_ColoringControls(ByRef $aFD)
    #forceref $aFD
    ; and here will color the controls

EndFunc

Func OnForm_Close()
    GUIDelete()
    Exit
EndFunc   ;==>OnForm_Close

Func WindowsColorConstants()
    ; Windows Color Constants ; https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor
    Local $n, $WinSysColors[37][20]
    $WinSysColors[0][0] = 36
    $WinSysColors[1][0] = "COLOR_SCROLLBAR"
    $WinSysColors[2][0] = "COLOR_BACKGROUND"
    $WinSysColors[3][0] = "COLOR_ACTIVECAPTION"
    $WinSysColors[4][0] = "COLOR_INACTIVECAPTION"
    $WinSysColors[5][0] = "COLOR_MENU"
    $WinSysColors[6][0] = "COLOR_WINDOW"
    $WinSysColors[7][0] = "COLOR_WINDOWFRAME"
    $WinSysColors[8][0] = "COLOR_MENUTEXT"
    $WinSysColors[9][0] = "COLOR_WINDOWTEXT"
    $WinSysColors[10][0] = "COLOR_CAPTIONTEXT"
    $WinSysColors[11][0] = "COLOR_ACTIVEBORDER"
    $WinSysColors[12][0] = "COLOR_INACTIVEBORDER"
    $WinSysColors[13][0] = "COLOR_APPWORKSPACE"
    $WinSysColors[14][0] = "COLOR_HIGHLIGHT"
    $WinSysColors[15][0] = "COLOR_HIGHLIGHTTEXT"
    $WinSysColors[16][0] = "COLOR_BTNFACE"
    $WinSysColors[17][0] = "COLOR_BTNSHADOW"
    $WinSysColors[18][0] = "COLOR_GRAYTEXT"
    $WinSysColors[19][0] = "COLOR_BTNTEXT"
    $WinSysColors[20][0] = "COLOR_INACTIVECAPTIONTEXT"
    $WinSysColors[21][0] = "COLOR_BTNHIGHLIGHT"
    $WinSysColors[22][0] = "COLOR_3DDKSHADOW"
    $WinSysColors[23][0] = "COLOR_3DLIGHT"
    $WinSysColors[24][0] = "COLOR_INFOTEXT"
    $WinSysColors[25][0] = "COLOR_INFOBK"
    $WinSysColors[26][0] = "COLOR_HOTLIGHT"
    $WinSysColors[27][0] = "COLOR_GRADIENTACTIVECAPTION"
    $WinSysColors[28][0] = "COLOR_GRADIENTINACTIVECAPTION"
    $WinSysColors[29][0] = "COLOR_MENUHILIGHT"
    $WinSysColors[30][0] = "COLOR_MENUBAR"
    For $n = 1 To 25
        $WinSysColors[$n][1] = $n - 1
    Next
    For $n = 26 To 30
        $WinSysColors[$n][1] = $n
    Next
    $WinSysColors[31][0] = "COLOR_DESKTOP"
    $WinSysColors[31][1] = 1
    $WinSysColors[32][0] = "COLOR_3DFACE"
    $WinSysColors[32][1] = 15
    $WinSysColors[33][0] = "COLOR_3DSHADOW"
    $WinSysColors[33][1] = 16
    $WinSysColors[34][0] = "COLOR_3DHIGHLIGHT"
    $WinSysColors[35][0] = "COLOR_3DHILIGHT"
    $WinSysColors[36][0] = "COLOR_BTNHILIGHT"
    $WinSysColors[34][1] = 20
    $WinSysColors[35][1] = 20
    $WinSysColors[36][1] = 20

    $WinSysColors[1][2] = "COLOR_SCROLLBAR"
    $WinSysColors[2][2] = "COLOR_BACKGROUND"
    $WinSysColors[3][2] = "COLOR_ACTIVECAPTION"
    $WinSysColors[4][2] = "COLOR_INACTIVECAPTION"
    $WinSysColors[5][2] = "COLOR_MENU"
    $WinSysColors[6][2] = "COLOR_WINDOW"
    $WinSysColors[7][2] = "COLOR_WINDOWFRAME"
    $WinSysColors[8][2] = "COLOR_MENUTEXT"
    $WinSysColors[9][2] = "COLOR_WINDOWTEXT"
    $WinSysColors[10][2] = "COLOR_CAPTIONTEXT"
    $WinSysColors[11][2] = "COLOR_ACTIVEBORDER"
    $WinSysColors[12][2] = "COLOR_INACTIVEBORDER"
    $WinSysColors[13][2] = "COLOR_APPWORKSPACE"
    $WinSysColors[14][2] = "COLOR_HIGHLIGHT"
    $WinSysColors[15][2] = "COLOR_HIGHLIGHTTEXT"
    $WinSysColors[16][2] = "COLOR_BTNFACE"
    $WinSysColors[17][2] = "COLOR_BTNSHADOW"
    $WinSysColors[18][2] = "COLOR_GRAYTEXT"
    $WinSysColors[19][2] = "COLOR_BTNTEXT"
    $WinSysColors[20][2] = "COLOR_INACTIVECAPTIONTEXT"
    $WinSysColors[21][2] = "COLOR_BTNHIGHLIGHT"
    $WinSysColors[22][2] = "COLOR_3DDKSHADOW"
    $WinSysColors[23][2] = "COLOR_3DLIGHT"
    $WinSysColors[24][2] = "COLOR_INFOTEXT"
    $WinSysColors[25][2] = "COLOR_INFOBK"
    $WinSysColors[26][2] = "COLOR_HOTLIGHT"
    $WinSysColors[27][2] = "COLOR_GRADIENTACTIVECAPTION"
    $WinSysColors[28][2] = "COLOR_GRADIENTINACTIVECAPTION"
    $WinSysColors[29][2] = "COLOR_MENUHILIGHT"
    $WinSysColors[30][2] = "COLOR_MENUBAR"

    Return $WinSysColors
EndFunc   ;==>WindowsColorConstants

it does not have to be this approach. If you have a better way to do it, that is good help too.

Edited by argumentum
2019.11.14 code update

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

I got it to work with GDIPlus... it's not perfect, but it's a start :)

#Region ### Create Background Labels ###
; Note this needs to be used when the GUI is visible!

_GDIPlus_Startup()

_DrawAlphaLabel("X", $iLeft + $iWidth - 115, $iTop + 30, 30, 30, 0x55800000, 0xFF000000)
_DrawAlphaLabel("#", $iLeft + $iWidth - 147, $iTop + 30, 30, 30, 0x55800000, 0xFF000000)
_DrawAlphaLabel("_", $iLeft + $iWidth - 179, $iTop + 30, 30, 30, 0x55800000, 0xFF000000)

_GDIPlus_Shutdown()

#EndRegion ### Create Background Labels ###


Func _DrawAlphaLabel($sText, $iLeft, $iTop, $iWidth, $iHeight, $vBackColor, $vTextColor)

    $hGraphic =_GDIPlus_GraphicsCreateFromHWND($Form)
    $hBrush = _GDIPlus_BrushCreateSolid($vTextColor)
    $hBrushFill = _GDIPlus_BrushCreateSolid($vBackColor)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 8)
    $tLayout = _GDIPlus_RectFCreate($iLeft + $iWidth/4, $iTop + $iHeight/4, $iWidth, $iHeight)

    _GDIPlus_GraphicsFillRect($hGraphic, $iLeft, $iTop, $iWidth, $iHeight, $hBrushFill)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $tLayout, $hFormat, $hBrush)

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BrushDispose($hBrushFill)
    _GDIPlus_GraphicsDispose($hGraphic)

EndFunc

 

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Thanks for sharing @seadoggie01, but I've got the part. What I don't have is the alphaing of the Inactive window.
what I've done image.png.6e58c87dc22c95e0671f096b04d049ed.png  vs,   image.png how it looks in reality.

what I believe is needed, is a calculation for the color representation of the alpha that is used in Windows 10 for the inactive window.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Sorry should've explained... the brush color is an 8 digit hex code... the first 2 digits relate to the value of the Alpha... see this website to get the alpha value you want, and slap it in front of your normal 6 digit hex color... this is similar to the RGBA() function of CSS/Html except that the alpha is at the front and converted to a hex. Go figure :D

I don't know how to calculate the alpha from you pictures if that's what you mean... and if so, ignore the top of this, sorry. I tried reading the Wiki article related to it, but got lost.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

2 minutes ago, seadoggie01 said:

I don't know how to calculate the alpha

ok, I don't know GDI but, is there a way to "flatten" the AARRGGBB to RRGGBB ?, maybe by reading back the brush ? ( I don't know what am saying but I home it makes sense ).
Or, apply AARRGGBB  to a Control ?. In any case I'll need the calculation of adding 2 AARRGGBB colors  :(

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

23 minutes ago, argumentum said:

is there a way to "flatten" the AARRGGBB to RRGGBB ?

Unless you mean dropping it entirely no. The AA is the alpha bit, which determines just how transparent it is

25 minutes ago, argumentum said:

Or, apply AARRGGBB  to a Control?

I looked for that, but I couldn't find it... that's why I drew it out with GDIPlus :)

Are you trying to implement the transparency on an inactive window, or just draw something transparent inside of a GUI? I thought you were trying to just draw inside a GUI

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

image.png

In this image ( active and inactive windows ), the inactive color is a merge of colors via alpha...something.
But don't go too far with it if is not within you experience.
For what I see, this is not as simple as it would have been with a HighContrast on WinXP.
Win10 don't respect their prior SysColor everywhere, so I may not be able to recreate a great deal of visual fidelity to that is found on screen anyway.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

In that image, they've combined the front window's colors with the black of the background by making the edges of the window transparent. What I'm confused about now though, is whether you're trying to re-create this effect on the edges of a GUI for a program or simulate this inside of the program that you've posted. I have no idea on the first, but with the second, I think I can help... see this thread. :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Maybe you can use this function to dimm the color of the inactive window.

 

Func ReduceRGBColorChannels($iColor, $fFactor = 0.5, $bAlpha = False)
    Local $a, $r, $g, $b
    $a = BitAND(0xFF, BitShift($iColor, 24))
    $a = $a < 0 ? 0 : $a > 255 ? 255 : $a
    $r = BitShift(BitAND(0xFF0000, $iColor), 16) * $fFactor
    $r = $r < 0 ? 0 : $r > 255 ? 255 : $r
    $g = BitShift(BitAND(0xFF00, $iColor), 8) * $fFactor
    $g = $g < 0 ? 0 : $g > 255 ? 255 : $g
    $b = BitAND(0xFF, $iColor) * $fFactor
    $b = $b < 0 ? 0 : $b > 255 ? 255 : $b
    $a = $bAlpha ? $a * $fFactor : $a
    Return BitOR(BitShift($a, -24), BitShift($r, -16), BitShift($g, -8), $b)
EndFunc

Local $iColor = 0xFFABCDEF
ConsoleWrite(Hex($iColor, 8) & " -> 0x" & Hex(ReduceRGBColorChannels($iColor), 8) & @CRLF)

 

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ's function will work if you just need to merge the color with black, but if you want to merge any two colors together, you can try this:

Func _ColorMerge($iBaseColor, $iMergeColor)
    Local $aBase[3] = [ _
        BitAND(BitShift($iBaseColor, 16), 0xff), _ ; R
        BitAND(BitShift($iBaseColor, 8), 0xff), _  ; G
        BitAND($iBaseColor, 0xff) ]                ; B

    Local $aMerge[3] = [ _
        BitAND(BitShift($iMergeColor, 16), 0xff), _ ; R
        BitAND(BitShift($iMergeColor, 8), 0xff), _  ; G
        BitAND($iMergeColor, 0xff) ]                ; B

    Local $aReturn[3], $nAlpha = BitAND(BitShift($iMergeColor, 24), 0xff) / 255

    For $i = 0 To 2
        $aReturn[$i] = Round($aBase[$i] * (1-$nAlpha) + $aMerge[$i] * $nAlpha)
    Next

    Return BitOR(0xff000000, BitShift($aReturn[0], -16), BitShift($aReturn[1], -8), $aReturn[2])
EndFunc


ConsoleWrite(Hex(_ColorMerge(0xFF0000, 0x80FFFF00)) & @CRLF) ; Red plus 50% yellow = orange (#ff8000)

Consider the first color as a background, it has no alpha value (technically it defaults to 100%). The second color requires an alpha value. The return is a full AARRGGBB color value.

Link to comment
Share on other sites

..I believe that this code ( html file attached below ), is what I need, but I can't get the JS to AutoIt, due to not understanding the JS. 😫
Could you translate it ?  :thumbsup:

after testing, a lot, found that this code is not perfect :( 

Thanks

ColorBlender.html

PS: I need it with 9 midpoints.

PS2: ..just a function to return the colors. Don't need a GUI.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

I can't decode it, but I can explain it :) They're splitting the color into RGB, calculating the difference, and splitting the difference into equally spaced groups... it's easiest to see if you look at it with RGB% instead of Hex

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Hehe, nope! I can't think though hex values at all :D

In all seriousness, I think it would be something like this: (but this is for integers, so Idk if it will work)

#include <Array.au3>

_ArrayDisplay(CalcRGBAvg(20, 50, 100, 0, 0, 0))
_ArrayDisplay(CalcRGBAvg(0, 0, 255, 255, 0, 0))

Func CalcRGBAvg($iRed, $iGreen, $iBlue, $iRed2, $iGreen2, $iBlue2, $iMidPoints = 9)
    ; Add one to midpoints... don't know why :D
    $iMidPoints += 1
    Local $aColors[0]
    Local $iRedDiff = Abs($iRed - $iRed2)
    Local $bRedRev = ($iRedDiff = $iRed-$iRed2)
    Local $iGreenDiff = Abs($iGreen - $iGreen2)
    Local $bGreenRev = ($iGreenDiff = $iGreen-$iGreen2)
    Local $iBlueDiff = Abs($iBlue - $iBlue2)
    Local $bBlueRev = ($iBlueDiff = $iBlue-$iBlue2)

    For $i=0 to $iMidPoints
        _ArrayAdd($aColors, "RGB(" & _
            Abs(($bRedRev ? 0 : -255) + $iRedDiff/$iMidPoints * $i) & ", " & _
            Abs(($bGreenRev ? 0 : -255) + $iGreenDiff/$iMidPoints * $i) & ", " & _
            Abs(($bBlueRev ? 0 : -255) + $iBlueDiff/$iMidPoints * $i) & ")")
    Next
    Return $aColors

EndFunc

Edit: Fixed, I think

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

9 minutes ago, seadoggie01 said:

I think it would be something like this

..if you try CalcRGBAvg(0, 0, 255, 255, 0, 0)  Blue To Red  you'll see that the last color is 0,0,0 and the first is 255,0,255
So that is not it  :(

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Oh, I see what I did... give me a minute, they need to be ordered. Should've tested before posting 😐

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Well... now it's ugly, but it works somehow. I'm still trying to figure out hex values, but I'm not getting much of anywhere. Can you convert hex to integers? I keep trying but I seem to misunderstand. I thought 0x00000F = 16, but AutoIt is telling me that it's 21

Edited by seadoggie01
It says 21, not 22

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

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...